Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Stop background Git maintenance in Open Knowledge test fixtures (#5591)
Nick Gomezd7dc10c8e778
diff --git a/packages/app/tests/integration/asset-move-rerenders-embeds.test.ts b/packages/app/tests/integration/asset-move-rerenders-embeds.test.tsindex d1145fd8f..409a5b1ee 100644--- a/packages/app/tests/integration/asset-move-rerenders-embeds.test.ts+++ b/packages/app/tests/integration/asset-move-rerenders-embeds.test.ts@@ -5,6 +5,7 @@ import { setTimeout as wait } from 'node:timers/promises';import { ensureProjectGit } from '@inkeep/open-knowledge-server';import { yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { ProviderPool } from '../../src/editor/provider-pool';import { createRestartableServer, getServerState, pollUntil, schema } from './test-harness';@@ -50,6 +51,7 @@ describe('asset-move embed re-resolution — head-watcher-independent fallback',writeRel(contentDir, 'photo.png', PNG_BYTES);writeRel(contentDir, 'assets/cover.md', '# Cover\n');await ensureProjectGit(contentDir);+ configureTestGitRepository(contentDir);const server = await createRestartableServer({contentDir,@@ -133,6 +135,7 @@ describe('asset-move embed re-resolution — head-watcher-independent fallback',writeRel(contentDir, 'test-doc.md', DOC_BODY);writeRel(contentDir, 'photo.png', PNG_BYTES);await ensureProjectGit(contentDir);+ configureTestGitRepository(contentDir);const server = await createRestartableServer({contentDir,diff --git a/packages/app/tests/integration/branch-switch-live-client.test.ts b/packages/app/tests/integration/branch-switch-live-client.test.tsindex 13960437e..a9b263c66 100644--- a/packages/app/tests/integration/branch-switch-live-client.test.ts+++ b/packages/app/tests/integration/branch-switch-live-client.test.ts@@ -7,6 +7,7 @@ import { HocuspocusProvider } from '@hocuspocus/provider';import { ensureProjectGit } from '@inkeep/open-knowledge-server';import { afterEach, describe, expect, test } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { handleBranchSwitched } from '../../src/editor/branch-invalidation';import { ProviderPool } from '../../src/editor/provider-pool';import { parseCC1BranchSwitched, SYSTEM_DOC_NAME } from '../../src/lib/cc1';@@ -63,6 +64,7 @@ async function setupGitRepoWithBranches(contentB: string,): Promise<void> {await ensureProjectGit(contentDir);+ configureTestGitRepository(contentDir);git(contentDir, 'config user.name test');git(contentDir, 'config user.email [email protected]');writeFileSync(join(contentDir, `${docName}.md`), contentA, 'utf-8');diff --git a/packages/app/tests/integration/branch-switch-private-state-link.test.ts b/packages/app/tests/integration/branch-switch-private-state-link.test.tsindex e5b3c4ed8..5f578d6e4 100644--- a/packages/app/tests/integration/branch-switch-private-state-link.test.ts+++ b/packages/app/tests/integration/branch-switch-private-state-link.test.ts@@ -5,6 +5,7 @@ import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';import { ensureProjectGit } from '@inkeep/open-knowledge-server';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { createRestartableServer, createTestClient, pollUntil } from './test-harness';const cleanups: Array<() => Promise<void> | void> = [];@@ -38,6 +39,7 @@ describe('branch switch with a document that became a link into private state',const contentDir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-branch-switch-private-')));cleanups.push(() => rmSync(contentDir, { recursive: true, force: true }));await ensureProjectGit(contentDir);+ configureTestGitRepository(contentDir);git(contentDir, 'config user.name test');git(contentDir, 'config user.email [email protected]');mkdirSync(join(contentDir, '.ok', 'local'), { recursive: true });diff --git a/packages/app/tests/integration/branch-switched-with-stale-embed-resolution.test.ts b/packages/app/tests/integration/branch-switched-with-stale-embed-resolution.test.tsindex 76ac9216e..fbbeb82a5 100644--- a/packages/app/tests/integration/branch-switched-with-stale-embed-resolution.test.ts+++ b/packages/app/tests/integration/branch-switched-with-stale-embed-resolution.test.ts@@ -6,6 +6,7 @@ import { setTimeout as wait } from 'node:timers/promises';import { ensureProjectGit } from '@inkeep/open-knowledge-server';import { yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { ProviderPool } from '../../src/editor/provider-pool';import { createRestartableServer, getServerState, pollUntil, schema } from './test-harness';@@ -66,6 +67,7 @@ describe('T17: branch switch with `![[photo.png]]` doc — reseed-before-reset',writeRel(contentDir, 'test-doc.md', DOC_BODY);writeRel(contentDir, 'photo.png', PNG_BYTES);await ensureProjectGit(contentDir);+ configureTestGitRepository(contentDir);git(contentDir, 'config user.name test');git(contentDir, 'config user.email [email protected]');git(contentDir, 'add .');diff --git a/packages/app/tests/integration/conflict-aware-write-surfaces.test.ts b/packages/app/tests/integration/conflict-aware-write-surfaces.test.tsindex d0f17473f..cd30dc524 100644--- a/packages/app/tests/integration/conflict-aware-write-surfaces.test.ts+++ b/packages/app/tests/integration/conflict-aware-write-surfaces.test.ts@@ -4,6 +4,7 @@ import { dirname, join } from 'node:path';import { promisify } from 'node:util';import { bootServer, ConfigSchema, getLocalDir } from '@inkeep/open-knowledge-server';import { describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { createTestClient, createTestServer, pollUntil, type TestServer } from './test-harness';const execFileAsync = promisify(execFile);@@ -235,6 +236,7 @@ describe('FR12: /api/sync/conflicts + /api/sync/status count parity', () => {mkdirSync(join(tmpDir, '.ok'), { recursive: true });writeFileSync(join(tmpDir, '.ok', 'config.yml'), '', 'utf-8');await execFileAsync('git', ['init', '--initial-branch=main', tmpDir]);+ configureTestGitRepository(tmpDir);const fileA = `fr12-a-${crypto.randomUUID()}.md`;const fileB = `fr12-b-${crypto.randomUUID()}.md`;@@ -295,6 +297,7 @@ describe('FR14: a conflicts.json present at construction gates writes (in-procesmkdirSync(join(tmpDir, '.ok'), { recursive: true });writeFileSync(join(tmpDir, '.ok', 'config.yml'), '', 'utf-8');await execFileAsync('git', ['init', '--initial-branch=main', tmpDir]);+ configureTestGitRepository(tmpDir);const docName = `fr14-fn-${crypto.randomUUID()}`;await seedRealMergeConflict(tmpDir, [`${docName}.md`]);@@ -342,6 +345,7 @@ describe('a conflict raised while the doc was unloaded still gates its first loacleanups.push(() => rmSync(tmpDir, { recursive: true, force: true }));await execFileAsync('git', ['init', '--initial-branch=main', tmpDir]);+ configureTestGitRepository(tmpDir);mkdirSync(join(tmpDir, '.ok'), { recursive: true });writeFileSync(join(tmpDir, '.ok', 'config.yml'), '', 'utf-8');writeFileSync(join(tmpDir, '.ok', '.gitignore'), '', 'utf-8');@@ -403,6 +407,7 @@ describe('FR14: boot-time conflict admission from conflicts.json', () => {cleanups.push(() => rmSync(tmpDir, { recursive: true, force: true }));await execFileAsync('git', ['init', '--initial-branch=main', tmpDir]);+ configureTestGitRepository(tmpDir);mkdirSync(join(tmpDir, '.ok'), { recursive: true });writeFileSync(join(tmpDir, '.ok', 'config.yml'), '', 'utf-8');writeFileSync(join(tmpDir, '.ok', '.gitignore'), '', 'utf-8');@@ -518,6 +523,7 @@ describe('FR17: Conflicts list HTTP shape (data feed the sidebar section consumemkdirSync(join(tmpDir, '.ok'), { recursive: true });writeFileSync(join(tmpDir, '.ok', 'config.yml'), '', 'utf-8');await execFileAsync('git', ['init', '--initial-branch=main', tmpDir]);+ configureTestGitRepository(tmpDir);const fileA = `fr17-a-${crypto.randomUUID()}.md`;const fileB = `fr17-b-${crypto.randomUUID()}.md`;@@ -560,6 +566,7 @@ describe('FR17: Conflicts list HTTP shape (data feed the sidebar section consumemkdirSync(join(tmpDir2, '.ok'), { recursive: true });writeFileSync(join(tmpDir2, '.ok', 'config.yml'), '', 'utf-8');await execFileAsync('git', ['init', '--initial-branch=main', tmpDir2]);+ configureTestGitRepository(tmpDir2);const server2 = await createTestServer({ contentDir: tmpDir2, keepContentDir: true });cleanups.push(() => server2.cleanup());const emptyRes = await fetch(`http://127.0.0.1:${server2.port}/api/sync/conflicts`);@@ -593,6 +600,7 @@ describe('a conflicted doc under a content.dir subdirectory reports its ledger fcleanups.push(() => rmSync(projectDir, { recursive: true, force: true }));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);mkdirSync(join(projectDir, '.ok'), { recursive: true });writeFileSync(join(projectDir, '.ok', 'config.yml'), '', 'utf-8');writeFileSync(join(projectDir, '.ok', '.gitignore'), '', 'utf-8');diff --git a/packages/app/tests/integration/conflict-resolution-delete-modify.test.ts b/packages/app/tests/integration/conflict-resolution-delete-modify.test.tsindex 77132ca53..c0c0d2950 100644--- a/packages/app/tests/integration/conflict-resolution-delete-modify.test.ts+++ b/packages/app/tests/integration/conflict-resolution-delete-modify.test.ts@@ -5,6 +5,7 @@ import { join } from 'node:path';import { promisify } from 'node:util';import { ProblemDetailsSchema } from '@inkeep/open-knowledge-core';import { afterAll, beforeAll, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { HARNESS_BOOT_TIMEOUT_MS } from './harness-boot-timeout';import { createTestServer, pollUntil, type TestServer } from './test-harness';@@ -83,6 +84,7 @@ async function createDUTestServer(): Promise<TestServer> {mkdirSync(join(dir, '.ok'), { recursive: true });writeFileSync(join(dir, '.ok', 'config.yml'), '', 'utf-8');await execFileAsync('git', ['init', '--initial-branch=main', dir]);+ configureTestGitRepository(dir);await setupDUConflict(dir);await registerConflict(dir, 'foo.md');return createTestServer({ contentDir: dir, keepContentDir: false });@@ -94,6 +96,7 @@ async function createUDTestServer(): Promise<TestServer> {mkdirSync(join(dir, '.ok'), { recursive: true });writeFileSync(join(dir, '.ok', 'config.yml'), '', 'utf-8');await execFileAsync('git', ['init', '--initial-branch=main', dir]);+ configureTestGitRepository(dir);await setupUDConflict(dir);await registerConflict(dir, 'foo.md');return createTestServer({ contentDir: dir, keepContentDir: false });@@ -255,6 +258,7 @@ describe('both-modified conflict — backward compatibility', () => {mkdirSync(join(contentDir, '.ok'), { recursive: true });writeFileSync(join(contentDir, '.ok', 'config.yml'), '', 'utf-8');await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);const opts = { cwd: contentDir };await execFileAsync('git', ['config', 'user.email', '[email protected]'], opts);await execFileAsync('git', ['config', 'user.name', 'Test'], opts);diff --git a/packages/app/tests/integration/idle-shutdown-multi-client.test.ts b/packages/app/tests/integration/idle-shutdown-multi-client.test.tsindex a38ca1575..c497f0ba6 100644--- a/packages/app/tests/integration/idle-shutdown-multi-client.test.ts+++ b/packages/app/tests/integration/idle-shutdown-multi-client.test.ts@@ -20,6 +20,7 @@ import {} from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, expect, test } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { HARNESS_BOOT_TIMEOUT_MS } from './harness-boot-timeout';import { waitForSync } from './test-harness.ts';@@ -33,6 +34,7 @@ let lockPath = '';beforeAll(async () => {contentDir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-idle-multi-')));await ensureProjectGit(contentDir);+ configureTestGitRepository(contentDir);const okDir = join(contentDir, OK_DIR);mkdirSync(okDir, { recursive: true });writeFileSync(join(okDir, 'config.yml'), '', 'utf-8');diff --git a/packages/app/tests/integration/sync-engine-dot-dir-symmetry.test.ts b/packages/app/tests/integration/sync-engine-dot-dir-symmetry.test.tsindex da9e3dca7..a2bdbab3c 100644--- a/packages/app/tests/integration/sync-engine-dot-dir-symmetry.test.ts+++ b/packages/app/tests/integration/sync-engine-dot-dir-symmetry.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { createContentFilter } from '@inkeep/open-knowledge-server';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { createTestConflictAuthority } from '../../../server/src/conflict-authority.test-helper.ts';import { SyncEngine } from '../../../server/src/sync-engine.ts';@@ -19,6 +20,7 @@ function makeRepo(): { projectDir: string; originDir: string } {tmpRoots.push(projectDir, originDir);git(projectDir, ['init', '-b', 'main']);+ configureTestGitRepository(projectDir);git(projectDir, ['config', 'user.name', 'Test User']);git(projectDir, ['config', 'user.email', '[email protected]']);mkdirSync(join(projectDir, '.ok'), { recursive: true });@@ -34,6 +36,7 @@ function makeRepo(): { projectDir: string; originDir: string } {git(projectDir, ['commit', '-m', 'seed dot-dir skill']);git(originDir, ['init', '--bare', '-b', 'main']);+ configureTestGitRepository(originDir);git(projectDir, ['remote', 'add', 'origin', originDir]);git(projectDir, ['push', '--set-upstream', 'origin', 'main']);return { projectDir, originDir };diff --git a/packages/app/tests/integration/test-harness.ts b/packages/app/tests/integration/test-harness.tsindex 2b77d358b..e930ae06f 100644--- a/packages/app/tests/integration/test-harness.ts+++ b/packages/app/tests/integration/test-harness.ts@@ -1,5 +1,12 @@import { execFile } from 'node:child_process';-import { mkdirSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';+import {+ existsSync,+ mkdirSync,+ mkdtempSync,+ readFileSync,+ realpathSync,+ writeFileSync,+} from 'node:fs';import { createServer as createHttpServer } from 'node:http';import { createServer as createNetServer, type Socket } from 'node:net';import { tmpdir } from 'node:os';@@ -43,6 +50,7 @@ import {import { getSchema } from '@tiptap/core';import { yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {ORIGIN_TEXT_TO_TREE,ORIGIN_TREE_TO_TEXT,@@ -139,7 +147,10 @@ export async function createTestServer(options: CreateTestServerOptions = {}): PmkdirSync(join(contentDir, '.claude', 'skills'), { recursive: true });}- await ensureProjectGit(contentDir);+ const gitSetup = await ensureProjectGit(contentDir);+ if (gitSetup.didInit || existsSync(join(contentDir, '.git', 'config'))) {+ configureTestGitRepository(contentDir);+ }}const port = await getFreePort();@@ -1060,6 +1071,7 @@ export async function createRestartableServer(}await ensureProjectGit(contentDir);+ configureTestGitRepository(contentDir);const port = options.port ?? (await getFreePort());const srv = createServer({@@ -1434,10 +1446,12 @@ export async function createSyncWiredTestServer(const originDir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-sync-origin-')));await runGit(originDir, ['init', '--bare']);+ configureTestGitRepository(originDir);await runGit(originDir, ['symbolic-ref', 'HEAD', 'refs/heads/main']);const authorDir = realpathSync(mkdtempSync(join(tmpdir(), 'ok-sync-author-')));await runGit(authorDir, ['init', '--initial-branch=main']);+ configureTestGitRepository(authorDir);await runGit(authorDir, ['config', 'user.email', '[email protected]']);await runGit(authorDir, ['config', 'user.name', 'Upstream Author']);await runGit(authorDir, ['remote', 'add', 'origin', originDir]);@@ -1449,6 +1463,7 @@ export async function createSyncWiredTestServer(const cloneParent = realpathSync(mkdtempSync(join(tmpdir(), 'ok-sync-clone-')));const clonePath = join(cloneParent, 'content');await runGit(cloneParent, ['clone', originDir, clonePath]);+ configureTestGitRepository(clonePath);const contentDir = realpathSync(clonePath);await runGit(contentDir, ['config', 'user.email', '[email protected]']);await runGit(contentDir, ['config', 'user.name', 'Follower']);diff --git a/packages/app/tests/integration/worktree-test-harness.ts b/packages/app/tests/integration/worktree-test-harness.tsindex 514dc1548..a251e9ec3 100644--- a/packages/app/tests/integration/worktree-test-harness.ts+++ b/packages/app/tests/integration/worktree-test-harness.ts@@ -2,6 +2,7 @@ import { execFileSync } from 'node:child_process';import { mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { resolve } from 'node:path';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';export interface LinkedWorktreeHandle {repoRoot: string;@@ -22,6 +23,7 @@ export function createLinkedWorktree(opts: CreateLinkedWorktreeOptions = {}): Liconst repoRoot = mkdtempSync(resolve(tmpdir(), `${prefix}-repo-`));execFileSync('git', ['init', '--initial-branch=main', repoRoot], { stdio: 'pipe' });+ configureTestGitRepository(repoRoot);execFileSync('git', ['-C', repoRoot, 'config', 'user.email', '[email protected]']);execFileSync('git', ['-C', repoRoot, 'config', 'user.name', 'Test']);writeFileSync(resolve(repoRoot, 'README.md'), '# test\n');@@ -32,6 +34,7 @@ export function createLinkedWorktree(opts: CreateLinkedWorktreeOptions = {}): LirmSync(worktreePath, { recursive: true, force: true });const branch = opts.branch ?? `feat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;execFileSync('git', ['-C', repoRoot, 'worktree', 'add', '-b', branch, worktreePath]);+ configureTestGitRepository(worktreePath);const worktreesDir = resolve(repoRoot, '.git/worktrees');const adminEntries = readdirSync(worktreesDir);diff --git a/packages/app/tests/meta/substrate-vocabulary-drift.uncached.test.ts b/packages/app/tests/meta/substrate-vocabulary-drift.uncached.test.tsindex 1497210be..80d978281 100644--- a/packages/app/tests/meta/substrate-vocabulary-drift.uncached.test.ts+++ b/packages/app/tests/meta/substrate-vocabulary-drift.uncached.test.ts@@ -12,6 +12,7 @@ import { tmpdir } from 'node:os';import { basename, dirname, join, relative, resolve } from 'node:path';import { describe, expect, test } from 'vitest';import { gitCleanEnv } from '../../../../scripts/git-clean-env.mjs';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { isTestOnlySourceFile } from '../../../../test-support/test-only-source-file.mjs';import { getRegisteredDescriptors } from '../../src/editor/registry/index.ts';@@ -152,6 +153,7 @@ describe('substrate vocabulary drift — every test reference must resolve', ()const root = mkdtempSync(join(tmpdir(), 'ok-substrate-vocabulary-drift-'));try {runGit(root, ['init', '-q']);+ configureTestGitRepository(root);const unregistered = `export const markup = '<div data-component-type="planted-unregistered-substrate"></div>';\n`;const plant = (path: string, content: string) => {mkdirSync(dirname(join(root, path)), { recursive: true });@@ -187,6 +189,7 @@ describe('substrate vocabulary drift — every test reference must resolve', ()const root = mkdtempSync(join(tmpdir(), 'ok-substrate-vocabulary-drift-'));try {runGit(root, ['init', '-q']);+ configureTestGitRepository(root);const dir = join(root, 'packages', 'a');mkdirSync(dir, { recursive: true });writeFileSync(join(dir, 'ignore-rules'), 'ignored/\n');@@ -204,6 +207,7 @@ describe('substrate vocabulary drift — every test reference must resolve', ()const root = mkdtempSync(join(tmpdir(), 'ok-substrate-vocabulary-drift-'));try {runGit(root, ['init', '-q']);+ configureTestGitRepository(root);const tests = join(root, 'packages', 'p', 'tests');mkdirSync(tests, { recursive: true });writeFileSync(join(tests, 'loop.test.ts'), '');diff --git a/packages/app/tests/stress/okf-generated-index-settings.e2e.ts b/packages/app/tests/stress/okf-generated-index-settings.e2e.tsindex dc4e0b59e..d78ee1bb6 100644--- a/packages/app/tests/stress/okf-generated-index-settings.e2e.ts+++ b/packages/app/tests/stress/okf-generated-index-settings.e2e.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import AxeBuilder from '@axe-core/playwright';import type { Page } from '@playwright/test';import { parse } from 'yaml';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {expect,openProjectPluginsPanel,@@ -84,6 +85,7 @@ test('Escape decline restores focus, confirmation creates indexes, and disablingworkerServer,}) => {execFileSync('git', ['init', '-q'], { cwd: workerServer.contentDir });+ configureTestGitRepository(workerServer.contentDir);await api.seedDocs([{name: 'home',diff --git a/packages/cli/src/commands/auth/command-host.test.ts b/packages/cli/src/commands/auth/command-host.test.tsindex 73ec75eb7..2ef088c92 100644--- a/packages/cli/src/commands/auth/command-host.test.ts+++ b/packages/cli/src/commands/auth/command-host.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import password from '@inquirer/password';import { afterEach, beforeEach, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';import { clearTokenFromAllBackends, FileBackend } from '../../auth/token-store.ts';import { shareNameCheckCommand } from '../share/name-check.ts';import { shareOwnersCommand } from '../share/owners.ts';@@ -35,6 +36,7 @@ beforeEach(() => {vi.stubEnv('HOME', home);vi.stubEnv('USERPROFILE', home);execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);vi.spyOn(process, 'cwd').mockReturnValue(projectDir);vi.spyOn(process.stderr, 'write').mockImplementation(() => true);});diff --git a/packages/cli/src/commands/auth/validate-host.test.ts b/packages/cli/src/commands/auth/validate-host.test.tsindex e4cd09869..227479dac 100644--- a/packages/cli/src/commands/auth/validate-host.test.ts+++ b/packages/cli/src/commands/auth/validate-host.test.ts@@ -3,6 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';import { error as errorColor } from '../../ui/colors.ts';import { gitHubHostRejection, resolveAuthHost, validateGitHubHost } from './validate-host.ts';@@ -119,6 +120,7 @@ describe('validateGitHubHost', () => {function seedOrigin(projectDir: string, url: string): void {execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);execFileSync('git', ['remote', 'add', 'origin', url], { cwd: projectDir });}@@ -213,6 +215,7 @@ describe('resolveAuthHost', () => {test('no remote at all resolves to github.com so a local project can still publish', () => {execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);expect(resolveAuthHost(undefined, projectDir)).toBe('github.com');});diff --git a/packages/cli/src/commands/clone-git-config-env.test.ts b/packages/cli/src/commands/clone-git-config-env.test.tsindex 520f6e1d9..d58bf9963 100644--- a/packages/cli/src/commands/clone-git-config-env.test.ts+++ b/packages/cli/src/commands/clone-git-config-env.test.ts@@ -16,6 +16,8 @@ import { shellSingleQuote } from '@inkeep/open-knowledge-core';import { UnsafeIncomingSymlinkError } from '@inkeep/open-knowledge-server';import simpleGit, { GitPluginError, type SimpleGitOptions } from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';+import { startGitHubStandIn } from '../../tests/support/github-stand-in.test-helper.ts';import type { GhDetectResult } from '../auth/gh-detect.ts';import { FileBackend } from '../auth/token-store.ts';import {@@ -25,9 +27,14 @@ import {buildCloneGitOptions,handleCloneFailure,resolveCloneAuth,- runClone,+ runClone as runCloneProduct,} from './clone.ts';-import { startGitHubStandIn } from './github-stand-in.test-helper.ts';++async function runClone(...args: Parameters<typeof runCloneProduct>) {+ const target = await runCloneProduct(...args);+ configureTestGitRepository(target);+ return target;+}const relayTokenGh = (): GhDetectResult => ({ available: true, token: 'ghs_relay_probe' });@@ -44,6 +51,7 @@ function seedBareRepo(bareDir: string, readme: string): void {mkdirSync(seedDir, { recursive: true });const git = (cwd: string, args: string[]) => execFileSync('git', args, { cwd, stdio: 'ignore' });git(seedDir, ['init', '--initial-branch=main']);+ configureTestGitRepository(seedDir);writeFileSync(join(seedDir, 'README.md'), readme, 'utf-8');git(seedDir, ['add', 'README.md']);git(seedDir, [@@ -58,6 +66,7 @@ function seedBareRepo(bareDir: string, readme: string): void {'seed',]);git(dirname(bareDir), ['clone', '--bare', seedDir, bareDir]);+ configureTestGitRepository(bareDir);}function writeCredentialHelper(helperPath: string, reply: string): string {@@ -386,6 +395,7 @@ describe('ok clone checks symlinks before checking anything out', () => {const git = (args: string[], input?: string) =>execFileSync('git', args, { cwd: seedDir, input, encoding: 'utf-8' });git(['init', '--initial-branch=main']);+ configureTestGitRepository(seedDir);writeFileSync(join(seedDir, 'README.md'), '# seeded\n', 'utf-8');git(['add', 'README.md']);for (const [path, target] of Object.entries(links)) {@@ -407,6 +417,7 @@ describe('ok clone checks symlinks before checking anything out', () => {cwd: dirname(bareDir),stdio: 'ignore',});+ configureTestGitRepository(bareDir);}beforeEach(() => {@@ -498,6 +509,7 @@ describe('ok clone checks symlinks before checking anything out', () => {cwd: bareDir,stdio: 'ignore',});+ configureTestGitRepository(bareDir);await expect(runClone(diff --git a/packages/cli/src/commands/clone.test.ts b/packages/cli/src/commands/clone.test.tsindex da1b6f744..5bca87caa 100644--- a/packages/cli/src/commands/clone.test.ts+++ b/packages/cli/src/commands/clone.test.ts@@ -6,6 +6,7 @@ import { pathToFileURL } from 'node:url';import { type Config, UnsafeIncomingSymlinkError } from '@inkeep/open-knowledge-server';import simpleGit, { type SimpleGitOptions } from 'simple-git';import { afterEach, beforeEach, describe, expect, it, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import type { ExecFileSyncFn, GhDetectResult } from '../auth/gh-detect.ts';import { detectGh } from '../auth/gh-detect.ts';import { FileBackend, type TokenStore } from '../auth/token-store.ts';@@ -770,6 +771,7 @@ describe('ensureOkExcludedFromGit', () => {cwd: mainRepoDir,stdio: ['ignore', 'ignore', 'ignore'],});+ configureTestGitRepository(mainRepoDir);execFileSync('git', ['config', 'user.email', '[email protected]'], { cwd: mainRepoDir });execFileSync('git', ['config', 'user.name', 'T'], { cwd: mainRepoDir });writeFileSync(join(mainRepoDir, 'README.md'), '# r\n', 'utf-8');@@ -782,6 +784,7 @@ describe('ensureOkExcludedFromGit', () => {cwd: mainRepoDir,stdio: ['ignore', 'ignore', 'ignore'],});+ configureTestGitRepository(linkedDir);try {const dotGit = readFileSync(join(linkedDir, '.git'), 'utf-8');expect(dotGit.startsWith('gitdir:')).toBe(true);@@ -1460,6 +1463,7 @@ describe('clone stores the remote URL verbatim, userinfo included', () => {const srcDir = join(base, 'seed');mkdirSync(srcDir);execFileSync('git', ['init', '--initial-branch=main'], { cwd: srcDir, stdio: 'ignore' });+ configureTestGitRepository(srcDir);execFileSync('git', ['config', 'user.email', '[email protected]'], { cwd: srcDir });execFileSync('git', ['config', 'user.name', 'T'], { cwd: srcDir });writeFileSync(join(srcDir, 'README.md'), '# seed\n', 'utf-8');@@ -1473,6 +1477,7 @@ describe('clone stores the remote URL verbatim, userinfo included', () => {const env = buildCloneAuthEnv({}, { PATH: process.env.PATH ?? '' });const git = simpleGit(buildCloneGitOptions(base, [redirect])).env(env);await git.clone(declaredUrl, targetDir, buildCloneArgs(null));+ configureTestGitRepository(targetDir);const config = readFileSync(join(targetDir, '.git', 'config'), 'utf-8');expect(config).toContain(`url = ${declaredUrl}`);diff --git a/packages/cli/src/commands/init.test.ts b/packages/cli/src/commands/init.test.tsindex 152f0730c..2e1b33bcd 100644--- a/packages/cli/src/commands/init.test.ts+++ b/packages/cli/src/commands/init.test.ts@@ -38,6 +38,7 @@ import {const PUBLISHED_CHAIN_ENTRY = { command: '/bin/sh', args: ['-l', '-c', CHAIN_V2] } as const;+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {createTomlConfigEngine,setTomlConfigEngineForTesting,@@ -59,13 +60,21 @@ import {resolveMcpScope,resolveRequestedContentDir,resolveSharingMode,- runInit,+ runInit as runInitProduct,writeEditorMcpConfig,writeUserMcpConfigs,} from './init.ts';const NATIVE_TOML_AVAILABLE = createTomlConfigEngine().backend === 'native';+async function runInit(...args: Parameters<typeof runInitProduct>) {+ const result = await runInitProduct(...args);+ if (result.didGitInit || existsSync(join(result.projectRoot, '.git', 'config'))) {+ configureTestGitRepository(result.projectRoot);+ }+ return result;+}+describe('runInit', () => {let testDir: string;let fakeHome: string;@@ -1672,6 +1681,7 @@ describe('runInit — projectRoot threading', () => {const sub = join(repo, 'sub');mkdirSync(sub, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);expect(existsSync(join(repo, '.git'))).toBe(true);const result = await runInit({@@ -1695,6 +1705,7 @@ describe('runInit — projectRoot threading', () => {const repo = join(fakeHome, 'flat-repo');mkdirSync(repo, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);const result = await runInit({cwd: repo,@@ -1716,6 +1727,7 @@ describe('runInit — projectRoot threading', () => {const sub = join(repo, 'subdir');mkdirSync(sub, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);const result = await runInit({cwd: sub,@@ -1736,6 +1748,7 @@ describe('runInit — projectRoot threading', () => {const sub = join(repo, 'notes');mkdirSync(sub, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);const result = await runInit({cwd: sub,@@ -1761,6 +1774,7 @@ describe('runInit — projectRoot threading', () => {const nested = join(repo, 'docs', 'guides');mkdirSync(nested, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);const result = await runInit({cwd: repo,@@ -1780,6 +1794,7 @@ describe('runInit — projectRoot threading', () => {const repo = join(fakeHome, 'repo-cd-escape');mkdirSync(repo, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);await expect(runInit({@@ -1798,6 +1813,7 @@ describe('runInit — projectRoot threading', () => {const sub = join(repo, 'notes');mkdirSync(sub, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);await runInit({cwd: repo,@@ -1829,6 +1845,7 @@ describe('runInit — projectRoot threading', () => {const repo = join(fakeHome, 'repo-scaffold-fail');mkdirSync(repo, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);const base = await runInit({cwd: repo,home: fakeHome,@@ -1858,6 +1875,7 @@ describe('runInit — projectRoot threading', () => {const sub = join(repo, 'notes');mkdirSync(sub, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);const result = await runInit({cwd: sub,@@ -1883,6 +1901,7 @@ describe('runInit — projectRoot threading', () => {const repo = join(fakeHome, 'repo-json-previewerr');mkdirSync(repo, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);const base = await runInit({cwd: repo,home: fakeHome,@@ -1902,6 +1921,7 @@ describe('runInit — projectRoot threading', () => {const repo = join(fakeHome, 'repo-json-flat');mkdirSync(repo, { recursive: true });Bun.spawnSync({ cmd: ['git', 'init', '-q', repo], stdout: 'ignore', stderr: 'ignore' });+ configureTestGitRepository(repo);const result = await runInit({cwd: repo,diff --git a/packages/cli/src/commands/share/publish-credential-helper.test.ts b/packages/cli/src/commands/share/publish-credential-helper.test.tsindex f9f79ac84..9e0c56c7b 100644--- a/packages/cli/src/commands/share/publish-credential-helper.test.ts+++ b/packages/cli/src/commands/share/publish-credential-helper.test.ts@@ -1,10 +1,26 @@import { execFileSync } from 'node:child_process';-import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import {+ existsSync,+ mkdirSync,+ mkdtempSync,+ readFileSync,+ realpathSync,+ rmSync,+ writeFileSync,+} from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { shellSingleQuote } from '@inkeep/open-knowledge-core';import type { Octokit } from '@octokit/rest';import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';+import {+ GITHUB_HOST,+ type GitHubStandIn,+ type PlainHttpInterceptor,+ startGitHubStandIn,+ startPlainHttpInterceptor,+} from '../../../tests/support/github-stand-in.test-helper.ts';import {type CliHelperCall,gitConfigParameter as configParameter,@@ -15,14 +31,15 @@ import {writeCliEntryLauncher,writeRecordingCredentialHelper,} from '../git-credential-fixtures.test-helper.ts';-import {- GITHUB_HOST,- type GitHubStandIn,- type PlainHttpInterceptor,- startGitHubStandIn,- startPlainHttpInterceptor,-} from '../github-stand-in.test-helper.ts';-import { type PublishResult, runPublishFlow } from './publish.ts';+import { type PublishResult, runPublishFlow as runPublishFlowProduct } from './publish.ts';++async function runPublishFlow(...args: Parameters<typeof runPublishFlowProduct>) {+ const result = await runPublishFlowProduct(...args);+ if (existsSync(join(args[0].projectDir, '.git', 'config'))) {+ configureTestGitRepository(args[0].projectDir);+ }+ return result;+}const CLONE_URL = `https://${GITHUB_HOST}/alice/demo.git`;const PUBLISH_TOKEN = 'ok-test-publish-token-the-stand-in-accepts';@@ -249,11 +266,14 @@ describe("share publish authenticates its github.com push only through the CLI'sconst git = (...args: string[]) =>execFileSync('git', args, { cwd: projectDir, stdio: 'ignore' });execFileSync('git', ['init', '--quiet', '--initial-branch=main', submoduleSource]);+ configureTestGitRepository(submoduleSource);execFileSync('git', ['-C', submoduleSource, 'commit', '--quiet', '--allow-empty', '-m', 'one']);git('init', '--quiet', '--initial-branch=main');+ configureTestGitRepository(projectDir);git('add', 'README.md');git('commit', '--quiet', '-m', 'a project');git('-c', 'protocol.file.allow=always', 'submodule', 'add', '--quiet', submoduleSource, 'sub');+ configureTestGitRepository(join(projectDir, 'sub'));git('-C', 'sub', 'remote', 'set-url', 'origin', `http://${GITHUB_HOST}/alice/sub.git`);git('-C', 'sub', 'commit', '--quiet', '--allow-empty', '-m', 'not yet pushed');git('add', '.');diff --git a/packages/cli/src/commands/share/publish-git-config-env.test.ts b/packages/cli/src/commands/share/publish-git-config-env.test.tsindex e3f0ac779..017ef25f7 100644--- a/packages/cli/src/commands/share/publish-git-config-env.test.ts+++ b/packages/cli/src/commands/share/publish-git-config-env.test.ts@@ -1,11 +1,20 @@import { execFileSync } from 'node:child_process';-import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { pathToFileURL } from 'node:url';import type { Octokit } from '@octokit/rest';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';-import { runPublishFlow } from './publish.ts';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';+import { runPublishFlow as runPublishFlowProduct } from './publish.ts';++async function runPublishFlow(...args: Parameters<typeof runPublishFlowProduct>) {+ const result = await runPublishFlowProduct(...args);+ if (existsSync(join(args[0].projectDir, '.git', 'config'))) {+ configureTestGitRepository(args[0].projectDir);+ }+ return result;+}function octokitCreatingRepoAt(cloneUrl: string): Octokit {return {@@ -38,6 +47,7 @@ describe('share publish honours the environment command-scope git config (GIT_COvi.stubEnv('GIT_COMMITTER_NAME', undefined);vi.stubEnv('GIT_COMMITTER_EMAIL', undefined);execFileSync('git', ['init', '--bare', bareRepo], { stdio: 'ignore' });+ configureTestGitRepository(bareRepo);writeFileSync(join(projectDir, 'README.md'), '# Hello\n', 'utf-8');});diff --git a/packages/cli/src/commands/share/publish.test.ts b/packages/cli/src/commands/share/publish.test.tsindex 8951601fa..bf3795569 100644--- a/packages/cli/src/commands/share/publish.test.ts+++ b/packages/cli/src/commands/share/publish.test.ts@@ -1,11 +1,24 @@import { execSync } from 'node:child_process';-import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import type { Octokit } from '@octokit/rest';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';-import { classifyOctokitError, runPublishFlow, sharePublishCommand } from './publish.ts';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';+import {+ classifyOctokitError,+ runPublishFlow as runPublishFlowProduct,+ sharePublishCommand,+} from './publish.ts';++async function runPublishFlow(...args: Parameters<typeof runPublishFlowProduct>) {+ const result = await runPublishFlowProduct(...args);+ if (existsSync(join(args[0].projectDir, '.git', 'config'))) {+ configureTestGitRepository(args[0].projectDir);+ }+ return result;+}interface FakeOctokitOptions {authLogin?: string;@@ -221,7 +234,9 @@ describe('runPublishFlow (error branches)', () => {test('idempotent retry: 422 + existing-repo-at-owner proceeds to push (e2e)', async () => {const bareRepo = mkdtempSync(join(tmpdir(), 'ok-share-publish-retry-bare-'));execSync('git init --bare', { cwd: bareRepo, stdio: 'ignore' });+ configureTestGitRepository(bareRepo);execSync('git init', { cwd: tmpDir, stdio: 'ignore' });+ configureTestGitRepository(tmpDir);execSync('git config user.name Test', { cwd: tmpDir });execSync('git config user.email [email protected]', { cwd: tmpDir });writeFileSync(join(tmpDir, 'README.md'), '# Hello\n', 'utf-8');@@ -301,8 +316,10 @@ describe('runPublishFlow (e2e against bare repo)', () => {mkdirSync(projectDir, { recursive: true });mkdirSync(bareRepo, { recursive: true });execSync('git init --bare', { cwd: bareRepo, stdio: 'ignore' });+ configureTestGitRepository(bareRepo);writeFileSync(join(projectDir, 'README.md'), '# Hello\n', 'utf-8');execSync('git init', { cwd: projectDir, stdio: 'ignore' });+ configureTestGitRepository(projectDir);execSync('git config user.name Test', { cwd: projectDir });execSync('git config user.email [email protected]', { cwd: projectDir });});diff --git a/packages/cli/src/commands/sharing/sharing.test.ts b/packages/cli/src/commands/sharing/sharing.test.tsindex 3b3180cf9..b8075bd55 100644--- a/packages/cli/src/commands/sharing/sharing.test.ts+++ b/packages/cli/src/commands/sharing/sharing.test.ts@@ -3,6 +3,7 @@ import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';import { sharingShareCommand } from './share.ts';import { sharingStatusCommand } from './status.ts';import { sharingUnshareCommand } from './unshare.ts';@@ -17,6 +18,7 @@ function initGitRepo(dir: string): void {cwd: dir,stdio: ['ignore', 'ignore', 'ignore'],});+ configureTestGitRepository(dir);execFileSync('git', ['config', 'user.email', '[email protected]'], { cwd: dir });execFileSync('git', ['config', 'user.name', 'T'], { cwd: dir });}diff --git a/packages/cli/src/commands/sync-credential-helper.test.ts b/packages/cli/src/commands/sync-credential-helper.test.tsindex 29ba29aab..20df80214 100644--- a/packages/cli/src/commands/sync-credential-helper.test.ts+++ b/packages/cli/src/commands/sync-credential-helper.test.ts@@ -16,6 +16,14 @@ import { pathToFileURL } from 'node:url';import { shellSingleQuote } from '@inkeep/open-knowledge-core';import { type Config, readServerLock, resolveLockDir } from '@inkeep/open-knowledge-server';import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';+import {+ GITHUB_HOST,+ type GitHubStandIn,+ type PlainHttpInterceptor,+ startGitHubStandIn,+ startPlainHttpInterceptor,+} from '../../tests/support/github-stand-in.test-helper.ts';import type { GhDetectResult } from '../auth/gh-detect.ts';import { FileBackend, type TokenStore } from '../auth/token-store.ts';import {@@ -27,13 +35,6 @@ import {writeCliCredentialStandIn,writeRecordingCredentialHelper,} from './git-credential-fixtures.test-helper.ts';-import {- GITHUB_HOST,- type GitHubStandIn,- type PlainHttpInterceptor,- startGitHubStandIn,- startPlainHttpInterceptor,-} from './github-stand-in.test-helper.ts';import { runSync } from './sync.ts';const ORIGIN_URL = `https://${GITHUB_HOST}/alice/demo.git`;@@ -290,6 +291,7 @@ describe("ok sync without a running server authenticates through OpenKnowledge'sconst git = (...args: string[]) =>execFileSync('git', args, { cwd: projectDir, stdio: 'ignore' });git('init', '--initial-branch=main');+ configureTestGitRepository(projectDir);git('commit', '--allow-empty', '-m', 'seed');(scenario.repository ?? originUpstreamOnGitHub)(git, started);git('commit', '--allow-empty', '-m', 'local work to push');@@ -879,6 +881,7 @@ describe("ok sync without a running server authenticates through OpenKnowledge'sokStoreToken: OK_TOKEN,repository: (git) => {execFileSync('git', ['init', '--quiet', '--bare', '--initial-branch=main', localRemote]);+ configureTestGitRepository(localRemote);git('remote', 'add', 'origin', urlOf(localRemote));git('push', localRemote, 'main:main');git('config', 'branch.main.remote', 'origin');@@ -1254,6 +1257,7 @@ describe("ok sync without a running server authenticates through OpenKnowledge'sgitHubAccepts: GH_TOKEN,repository: (git, github) => {execFileSync('git', ['init', '--quiet', '--initial-branch=main', submoduleSource]);+ configureTestGitRepository(submoduleSource);execFileSync('git', ['-C',submoduleSource,@@ -1272,6 +1276,7 @@ describe("ok sync without a running server authenticates through OpenKnowledge'ssubmoduleSource,'sub',);+ configureTestGitRepository(join(projectDir, 'sub'));git('-C', 'sub', 'remote', 'set-url', 'origin', `http://${GITHUB_HOST}/alice/sub.git`);git('commit', '--quiet', '-m', 'add the submodule');originUpstreamOnGitHub(git, github);@@ -1293,6 +1298,7 @@ describe("ok sync without a running server authenticates through OpenKnowledge'sgithub.repositoryDir('alice/demo.git'),upstreamWork,]);+ configureTestGitRepository(upstreamWork);execFileSync('git', ['-C',upstreamWork,@@ -1511,6 +1517,7 @@ describe("ok sync without a running server authenticates through OpenKnowledge'srepository: (git, github) => {const remote = github.repositoryDir(nestedRepository, ENTERPRISE_HOST);execFileSync('git', ['init', '--quiet', '--bare', '--initial-branch=main', remote]);+ configureTestGitRepository(remote);git('remote', 'add', 'origin', `https://${ENTERPRISE_HOST}/${nestedRepository}`);git('push', remote, 'main:main');git('config', 'branch.main.remote', 'origin');diff --git a/packages/cli/src/commands/sync-incoming-symlinks.test.ts b/packages/cli/src/commands/sync-incoming-symlinks.test.tsindex a31755aa6..392c135f7 100644--- a/packages/cli/src/commands/sync-incoming-symlinks.test.ts+++ b/packages/cli/src/commands/sync-incoming-symlinks.test.ts@@ -18,6 +18,7 @@ import {} from '@inkeep/open-knowledge-server';import simpleGit, { type SimpleGit } from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { FileBackend } from '../auth/token-store.ts';import { runSync, syncFailureMessage } from './sync.ts';@@ -35,11 +36,13 @@ beforeEach(async () => {projectDir = join(tmpDir, 'project');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');mkdirSync(join(sisterDir, 'notes'), { recursive: true });sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'notes', 'real.md'), '# real\n', 'utf-8');@@ -49,6 +52,7 @@ beforeEach(async () => {await sister.push('origin', 'main');await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);project = simpleGit(projectDir);await project.raw('config', 'user.name', 'Project');await project.raw('config', 'user.email', '[email protected]');diff --git a/packages/cli/src/integrations/resolve-project-root.test.ts b/packages/cli/src/integrations/resolve-project-root.test.tsindex c04d090d2..a5056468a 100644--- a/packages/cli/src/integrations/resolve-project-root.test.ts+++ b/packages/cli/src/integrations/resolve-project-root.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import { promisify } from 'node:util';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {isHomeDir,type ResolveProjectRootOptions,@@ -276,6 +277,7 @@ describe('resolveProjectRoot — integration with real git', () => {const docs = resolve(repo, 'docs');mkdirSync(docs, { recursive: true });await execFileAsync('git', ['init', '--initial-branch=main', repo]);+ configureTestGitRepository(repo);const opts: ResolveProjectRootOptions = { homeDir: fakeHome };const result = resolveProjectRoot(docs, opts);diff --git a/packages/cli/src/sharing/git-exclude.test.ts b/packages/cli/src/sharing/git-exclude.test.tsindex 6bb392221..d827da1eb 100644--- a/packages/cli/src/sharing/git-exclude.test.ts+++ b/packages/cli/src/sharing/git-exclude.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { OK_DIR } from '@inkeep/open-knowledge-core';import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {addOkPathsToGitExclude,formatTrackedRemediation,@@ -42,6 +43,7 @@ function initGitRepo(dir: string): void {cwd: dir,stdio: ['ignore', 'ignore', 'ignore'],});+ configureTestGitRepository(dir);execFileSync('git', ['config', 'user.email', '[email protected]'], { cwd: dir });execFileSync('git', ['config', 'user.name', 'Test User'], { cwd: dir });}@@ -317,6 +319,7 @@ describe('addOkPathsToGitExclude', () => {cwd: mainRepo,stdio: ['ignore', 'ignore', 'ignore'],});+ configureTestGitRepository(linkedWorktree);try {const dotGitContent = readFileSync(join(linkedWorktree, '.git'), 'utf-8');expect(dotGitContent.startsWith('gitdir:')).toBe(true);diff --git a/packages/cli/src/sharing/git-pathspec-name-invariance.test.ts b/packages/cli/src/sharing/git-pathspec-name-invariance.test.tsindex db63aed5e..dd4b902e9 100644--- a/packages/cli/src/sharing/git-pathspec-name-invariance.test.ts+++ b/packages/cli/src/sharing/git-pathspec-name-invariance.test.ts@@ -3,6 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { probeTrackedOkPaths } from './git-exclude.ts';let projectRoot = '';@@ -25,6 +26,7 @@ function writeSkillFile(name: string, body: string): string {beforeEach(() => {projectRoot = mkdtempSync(join(tmpdir(), 'ok-cli-pathspec-'));git(['init', '-q', '-b', 'main', '.']);+ configureTestGitRepository(projectRoot);git(['config', 'user.name', 'Test']);git(['config', 'user.email', '[email protected]']);writeFileSync(join(projectRoot, 'README.md'), '# seed\n', 'utf-8');diff --git a/packages/cli/src/commands/github-stand-in.test-helper.ts b/packages/cli/tests/support/github-stand-in.test-helper.tssimilarity index 98%rename from packages/cli/src/commands/github-stand-in.test-helper.tsrename to packages/cli/tests/support/github-stand-in.test-helper.tsindex 2859d0052..c96ec6bd4 100644--- a/packages/cli/src/commands/github-stand-in.test-helper.ts+++ b/packages/cli/tests/support/github-stand-in.test-helper.ts@@ -11,6 +11,7 @@ import type { AddressInfo } from 'node:net';import { devNull } from 'node:os';import { join } from 'node:path';import type { Duplex } from 'node:stream';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';export const GITHUB_HOST = 'github.com';@@ -324,6 +325,7 @@ export async function startGitHubStandIn(options: {execFileSync('git', ['init', '--quiet', '--bare', '--initial-branch=main', repository], {env: hermeticGitEnv(repositoriesRoot),});+ configureTestGitRepository(repository);}}const certificates = throwawayGitHubCertificates([...hosts.keys()]);diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.jsonindex 7e0489e2c..51d366b34 100644--- a/packages/cli/tsconfig.json+++ b/packages/cli/tsconfig.json@@ -5,6 +5,6 @@"noEmit": true,"allowImportingTsExtensions": true},- "include": ["src", "scripts/build-skill-assets.ts", "*.ts"],+ "include": ["src", "scripts/build-skill-assets.ts", "tests/support", "*.ts"],"exclude": ["node_modules", "dist", "**/*.test.ts"]}diff --git a/packages/core/src/git-pathspec.test.ts b/packages/core/src/git-pathspec.test.tsindex 95e25e809..69e6573a5 100644--- a/packages/core/src/git-pathspec.test.ts+++ b/packages/core/src/git-pathspec.test.ts@@ -3,6 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterAll, beforeAll, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { pathspecArgs, stripPathspecMagic, toPathspec } from './git-pathspec.ts';const HOSTILE_NAMES = [':colon.md', ':!bang.md', 'star*.md'] as const;@@ -17,6 +18,7 @@ function git(args: readonly string[], cwd = repo): string {beforeAll(() => {repo = mkdtempSync(join(tmpdir(), 'ok-git-pathspec-'));git(['init', '--initial-branch=main']);+ configureTestGitRepository(repo);git(['config', 'user.email', '[email protected]']);git(['config', 'user.name', 'Test']);for (const name of [...HOSTILE_NAMES, ...PLAIN_NAMES]) {diff --git a/packages/core/src/skills-catalog/acquire/acquire.test.ts b/packages/core/src/skills-catalog/acquire/acquire.test.tsindex 3b8d448e7..a1cc653df 100644--- a/packages/core/src/skills-catalog/acquire/acquire.test.ts+++ b/packages/core/src/skills-catalog/acquire/acquire.test.ts@@ -3,6 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterAll, beforeAll, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';import { SkillPreviewSchema } from '../schema.ts';import { fetchSource, parseSkillsShSource, parseSource, SkillFetchError } from './fetch.ts';import {@@ -535,12 +536,14 @@ describe('fetchSource', () => {env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null' },});git(['init', '-q']);+ configureTestGitRepository(repo);git(['config', 'user.email', '[email protected]']);git(['config', 'user.name', 't']);git(['add', '-A']);git(['commit', '-q', '-m', 'init']);const f = await fetchSource({ kind: 'git', url: repo });+ configureTestGitRepository(f.dir);try {expect(parseSkillDir(f.dir)?.name).toBe('cloned');} finally {@@ -558,6 +561,7 @@ describe('fetchSource', () => {env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null' },});git(['init', '-q']);+ configureTestGitRepository(repo);git(['config', 'user.email', '[email protected]']);git(['config', 'user.name', 't']);git(['add', '-A']);diff --git a/packages/core/src/util/atomic-temp-path.test.ts b/packages/core/src/util/atomic-temp-path.test.tsindex fda981aad..c98564ab2 100644--- a/packages/core/src/util/atomic-temp-path.test.ts+++ b/packages/core/src/util/atomic-temp-path.test.ts@@ -3,6 +3,7 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterAll, beforeAll, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {ATOMIC_TEMP_GLOB,ATOMIC_TEMP_INFIX,@@ -94,6 +95,7 @@ function globVerdicts(paths: readonly string[], ignoreCase: boolean): Map<stringbeforeAll(() => {repoDir = mkdtempSync(join(tmpdir(), 'ok-atomic-temp-glob-'));execFileSync('git', ['init', '-q'], { cwd: repoDir, stdio: 'pipe', env: gitEnv() });+ configureTestGitRepository(repoDir);writeFileSync(join(repoDir, '.git', 'info', 'exclude'), `${ATOMIC_TEMP_GLOB}\n`);});diff --git a/packages/desktop/src/main/create-new-project.test.ts b/packages/desktop/src/main/create-new-project.test.tsindex 1fabf6542..894212a79 100644--- a/packages/desktop/src/main/create-new-project.test.ts+++ b/packages/desktop/src/main/create-new-project.test.ts@@ -14,12 +14,13 @@ import { join, resolve } from 'node:path';import { ALL_EDITOR_IDS } from '@inkeep/open-knowledge-core';import { afterEach, beforeEach, describe, expect, test } from 'vitest';import { runningAsRoot } from '../../../../test-support/capabilities.test-helper.ts';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {CreateNewProjectError,folderState,type RunCreateNewDeps,resolveDefaultProjectsRoot,- runCreateNew,+ runCreateNew as runCreateNewProduct,sanitizeFolderName,} from './create-new-project.ts';import {@@ -28,6 +29,14 @@ import {discoverProject,} from './folder-admission.ts';+async function runCreateNew(...args: Parameters<typeof runCreateNewProduct>) {+ const result = await runCreateNewProduct(...args);+ if (!result.gitRootPromoted || existsSync(join(result.projectDir, '.git', 'config'))) {+ configureTestGitRepository(result.projectDir);+ }+ return result;+}+let tmpRoot: string;beforeEach(() => {diff --git a/packages/desktop/src/main/folder-admission.test.ts b/packages/desktop/src/main/folder-admission.test.tsindex 862e95263..7628a2e70 100644--- a/packages/desktop/src/main/folder-admission.test.ts+++ b/packages/desktop/src/main/folder-admission.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { promisify } from 'node:util';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {type DiscoverProjectOptions,type DiscoverProjectResult,@@ -789,6 +790,7 @@ describe('discoverProject — integration with real git', () => {const docs = resolve(repo, 'docs');mkdirSync(docs, { recursive: true });await execFileAsync('git', ['init', '--initial-branch=main', repo]);+ configureTestGitRepository(repo);const result = await discoverProject(docs, { homeDir: fakeHome, dirSizeProbe: null });@@ -804,6 +806,7 @@ describe('discoverProject — integration with real git', () => {const repo = resolve(fakeHome, 'integration-root');mkdirSync(repo, { recursive: true });await execFileAsync('git', ['init', '--initial-branch=main', repo]);+ configureTestGitRepository(repo);const result = await discoverProject(repo, { homeDir: fakeHome, dirSizeProbe: null });@@ -832,6 +835,7 @@ describe('discoverProject — D12 linked-worktree carveout', () => {mkdirSync(parent, { recursive: true });writeOkConfig(parent);await execFileAsync('git', ['init', '--initial-branch=main', parent]);+ configureTestGitRepository(parent);await execFileAsync('git', ['-C', parent, 'config', 'user.email', '[email protected]']);await execFileAsync('git', ['-C', parent, 'config', 'user.name', 'Test']);writeFileSync(resolve(parent, 'README.md'), '# parent\n');@@ -840,6 +844,7 @@ describe('discoverProject — D12 linked-worktree carveout', () => {const wt = resolve(parent, 'wt-feat');await execFileAsync('git', ['-C', parent, 'worktree', 'add', '-b', 'feat', wt]);+ configureTestGitRepository(wt);const result = await discoverProject(wt, {homeDir: fakeHome,@@ -876,6 +881,7 @@ describe('discoverProject — D12 linked-worktree carveout', () => {const repo = resolve(fakeHome, 'standalone-repo');mkdirSync(repo, { recursive: true });await execFileAsync('git', ['init', '--initial-branch=main', repo]);+ configureTestGitRepository(repo);await execFileAsync('git', ['-C', repo, 'config', 'user.email', '[email protected]']);await execFileAsync('git', ['-C', repo, 'config', 'user.name', 'Test']);writeFileSync(resolve(repo, 'README.md'), '# r\n');@@ -883,6 +889,7 @@ describe('discoverProject — D12 linked-worktree carveout', () => {await execFileAsync('git', ['-C', repo, 'commit', '-m', 'initial']);const wt = resolve(repo, 'wt-standalone');await execFileAsync('git', ['-C', repo, 'worktree', 'add', '-b', 'standalone', wt]);+ configureTestGitRepository(wt);const result = await discoverProject(wt, { homeDir: fakeHome, dirSizeProbe: null });@@ -897,6 +904,7 @@ describe('discoverProject — D12 linked-worktree carveout', () => {mkdirSync(parent, { recursive: true });writeOkConfig(parent);await execFileAsync('git', ['init', '--initial-branch=main', parent]);+ configureTestGitRepository(parent);await execFileAsync('git', ['-C', parent, 'config', 'user.email', '[email protected]']);await execFileAsync('git', ['-C', parent, 'config', 'user.name', 'Test']);writeFileSync(resolve(parent, 'README.md'), '# parent\n');@@ -905,6 +913,7 @@ describe('discoverProject — D12 linked-worktree carveout', () => {const wt = resolve(parent, 'wt-initialized');await execFileAsync('git', ['-C', parent, 'worktree', 'add', '-b', 'init-feat', wt]);+ configureTestGitRepository(wt);writeOkConfig(wt);const result = await discoverProject(wt, { homeDir: fakeHome, dirSizeProbe: null });diff --git a/packages/desktop/src/main/ipc/sharing.test.ts b/packages/desktop/src/main/ipc/sharing.test.tsindex e1ee189f4..be3c48789 100644--- a/packages/desktop/src/main/ipc/sharing.test.ts+++ b/packages/desktop/src/main/ipc/sharing.test.ts@@ -3,6 +3,7 @@ import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';import { handleSharingSetMode, handleSharingStatus } from './sharing.ts';function uniqueDir(prefix: string): string {@@ -15,6 +16,7 @@ function initGitRepo(dir: string): void {cwd: dir,stdio: ['ignore', 'ignore', 'ignore'],});+ configureTestGitRepository(dir);execFileSync('git', ['config', 'user.email', '[email protected]'], { cwd: dir });execFileSync('git', ['config', 'user.name', 'T'], { cwd: dir });}diff --git a/packages/desktop/src/main/list-git-worktrees.test.ts b/packages/desktop/src/main/list-git-worktrees.test.tsindex 9f74db8e6..2f28e201b 100644--- a/packages/desktop/src/main/list-git-worktrees.test.ts+++ b/packages/desktop/src/main/list-git-worktrees.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { promisify } from 'node:util';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { listGitWorktrees } from './list-git-worktrees.ts';const execFileAsync = promisify(execFile);@@ -28,6 +29,7 @@ async function makeRepoWithWorktrees(branches: string[]): Promise<TestRepoHandlemkdirSync(mainRepo);await git(mainRepo, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(mainRepo);await git(mainRepo, 'config', 'user.email', '[email protected]');await git(mainRepo, 'config', 'user.name', 'Test');writeFileSync(join(mainRepo, 'README.md'), '# main\n');@@ -39,6 +41,7 @@ async function makeRepoWithWorktrees(branches: string[]): Promise<TestRepoHandleconst wt = join(root, 'wt', branch);mkdirSync(join(root, 'wt'), { recursive: true });await git(mainRepo, 'worktree', 'add', '-b', branch, wt);+ configureTestGitRepository(wt);worktrees.set(branch, wt);}diff --git a/packages/desktop/src/main/ok-init.test.ts b/packages/desktop/src/main/ok-init.test.tsindex 20096df09..c3f5952c4 100644--- a/packages/desktop/src/main/ok-init.test.ts+++ b/packages/desktop/src/main/ok-init.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { promisify } from 'node:util';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { runOkInit } from './ok-init.ts';const execFileAsync = promisify(execFile);@@ -60,6 +61,7 @@ describe('runOkInit', () => {test('scaffolds .ok/ inside a main-checkout git directory', async () => {testRoot = realpathSync(mkdtempSync(join(tmpdir(), 'ok-init-main-')));await git(testRoot, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(testRoot);const result = await runOkInit(testRoot);expect(result.ok).toBe(true);if (result.ok === true) {@@ -75,6 +77,7 @@ describe('runOkInit', () => {const mainRepo = join(testRoot, 'main');mkdirSync(mainRepo);await git(mainRepo, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(mainRepo);await git(mainRepo, 'config', 'user.email', '[email protected]');await git(mainRepo, 'config', 'user.name', 'Test');writeFileSync(join(mainRepo, 'README.md'), '# main\n');@@ -82,6 +85,7 @@ describe('runOkInit', () => {await git(mainRepo, 'commit', '-m', 'initial');const wt = join(testRoot, 'wt-feat');await git(mainRepo, 'worktree', 'add', '-b', 'feat', wt);+ configureTestGitRepository(wt);const result = await runOkInit(wt);expect(result.ok).toBe(true);if (result.ok === true) {@@ -93,6 +97,7 @@ describe('runOkInit', () => {test('idempotent on already-initialized projects (no rewrite)', async () => {testRoot = realpathSync(mkdtempSync(join(tmpdir(), 'ok-init-main-')));await git(testRoot, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(testRoot);const first = await runOkInit(testRoot);expect(first.ok).toBe(true);const configPath = join(testRoot, '.ok', 'config.yml');@@ -107,6 +112,7 @@ describe('runOkInit', () => {test('coalesces concurrent calls on the same path', async () => {testRoot = realpathSync(mkdtempSync(join(tmpdir(), 'ok-init-main-')));await git(testRoot, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(testRoot);const [a, b, c] = await Promise.all([runOkInit(testRoot),runOkInit(testRoot),@@ -121,6 +127,7 @@ describe('runOkInit', () => {test('returns canonical realpath in result', async () => {testRoot = realpathSync(mkdtempSync(join(tmpdir(), 'ok-init-main-')));await git(testRoot, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(testRoot);const result = await runOkInit(testRoot);expect(result.ok).toBe(true);if (result.ok === true) {diff --git a/packages/desktop/src/main/read-git-dir-kind.test.ts b/packages/desktop/src/main/read-git-dir-kind.test.tsindex 18c0da66e..13f644fc5 100644--- a/packages/desktop/src/main/read-git-dir-kind.test.ts+++ b/packages/desktop/src/main/read-git-dir-kind.test.ts@@ -13,6 +13,7 @@ import { join } from 'node:path';import { promisify } from 'node:util';import { afterEach, describe, expect, test } from 'vitest';import { runningAsRoot } from '../../../../test-support/capabilities.test-helper.ts';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { readGitDirKind } from './read-git-dir-kind.ts';const execFileAsync = promisify(execFile);@@ -43,6 +44,7 @@ describe('readGitDirKind', () => {test('returns "directory" for a main checkout (.git is a directory)', async () => {testRoot = realpathSync(mkdtempSync(join(tmpdir(), 'gitdir-kind-')));await git(testRoot, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(testRoot);expect(readGitDirKind(testRoot)).toBe('directory');});@@ -51,6 +53,7 @@ describe('readGitDirKind', () => {const mainRepo = join(testRoot, 'main');mkdirSync(mainRepo);await git(mainRepo, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(mainRepo);await git(mainRepo, 'config', 'user.email', '[email protected]');await git(mainRepo, 'config', 'user.name', 'Test');writeFileSync(join(mainRepo, 'README.md'), '# main\n');@@ -58,6 +61,7 @@ describe('readGitDirKind', () => {await git(mainRepo, 'commit', '-m', 'initial');const wt = join(testRoot, 'wt-feat');await git(mainRepo, 'worktree', 'add', '-b', 'feat', wt);+ configureTestGitRepository(wt);expect(readGitDirKind(wt)).toBe('linked');});@@ -76,6 +80,7 @@ describe('readGitDirKind', () => {test('returns "absent" for a plain subfolder of a real repo (the .git is the ancestor\'s)', async () => {testRoot = realpathSync(mkdtempSync(join(tmpdir(), 'gitdir-kind-')));await git(testRoot, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(testRoot);const sub = join(testRoot, 'subfolder');mkdirSync(sub);expect(readGitDirKind(sub)).toBe('absent');diff --git a/packages/desktop/src/main/resolve-share-target.test.ts b/packages/desktop/src/main/resolve-share-target.test.tsindex bcf23b0a2..81b79736e 100644--- a/packages/desktop/src/main/resolve-share-target.test.ts+++ b/packages/desktop/src/main/resolve-share-target.test.ts@@ -5,6 +5,7 @@ import { join } from 'node:path';import { promisify } from 'node:util';import type { RecentProjectEntry } from '@inkeep/open-knowledge-core';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { filterShareEligibleRecents, resolveShareTarget } from './resolve-share-target.ts';import { annotateMissing, emptyState } from './state-store.ts';@@ -29,6 +30,7 @@ async function makeRepoWithWorktrees(branches: readonly string[]): Promise<TempRconst mainRepo = join(root, 'main');mkdirSync(mainRepo);await git(mainRepo, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(mainRepo);await git(mainRepo, 'config', 'user.email', '[email protected]');await git(mainRepo, 'config', 'user.name', 'Test');writeFileSync(join(mainRepo, 'README.md'), '# main\n');@@ -40,6 +42,7 @@ async function makeRepoWithWorktrees(branches: readonly string[]): Promise<TempRmkdirSync(join(root, 'wt'), { recursive: true });const wt = join(root, 'wt', branch.replace(/\//g, '-'));await git(mainRepo, 'worktree', 'add', '-b', branch, wt);+ configureTestGitRepository(wt);worktrees.set(branch, wt);}diff --git a/packages/desktop/src/main/worktree-inventory.test.ts b/packages/desktop/src/main/worktree-inventory.test.tsindex b591f04b8..a5d761b6a 100644--- a/packages/desktop/src/main/worktree-inventory.test.ts+++ b/packages/desktop/src/main/worktree-inventory.test.ts@@ -13,6 +13,7 @@ import { join } from 'node:path';import { promisify } from 'node:util';import type { BridgeWorktreeEntry } from '@inkeep/open-knowledge-core';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {classifyLocation,isAllowedInventoryAnchor,@@ -48,6 +49,7 @@ async function makeFixture(): Promise<Fixture> {writeFileSync(join(repo, 'packages', 'docs', 'README.md'), 'docs\n');writeFileSync(join(repo, 'packages', 'notes', 'README.md'), 'notes\n');await git(repo, 'init', '-b', 'main');+ configureTestGitRepository(repo);await git(repo, 'config', 'user.email', '[email protected]');await git(repo, 'config', 'user.name', 'Test');await git(repo, 'add', '.');@@ -56,7 +58,9 @@ async function makeFixture(): Promise<Fixture> {const external = join(root, 'repo-prefix-external');mkdirSync(join(repo, '.ok', 'worktrees'), { recursive: true });await git(repo, 'worktree', 'add', '-b', 'dev', internal);+ configureTestGitRepository(internal);await git(repo, 'worktree', 'add', '-b', 'external', external);+ configureTestGitRepository(external);return { root, repo, internal, external };}diff --git a/packages/desktop/src/main/worktree-recents.test.ts b/packages/desktop/src/main/worktree-recents.test.tsindex 172b8d48e..57d59d11d 100644--- a/packages/desktop/src/main/worktree-recents.test.ts+++ b/packages/desktop/src/main/worktree-recents.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { promisify } from 'node:util';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {classifyRecentGit,classifyRecentGitAsync,@@ -31,6 +32,7 @@ async function makeRepoWithWorktree(): Promise<Handle> {const mainRepo = join(root, 'main');mkdirSync(mainRepo);await git(mainRepo, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(mainRepo);await git(mainRepo, 'config', 'user.email', '[email protected]');await git(mainRepo, 'config', 'user.name', 'Test');writeFileSync(join(mainRepo, 'README.md'), '# main\n');@@ -39,6 +41,7 @@ async function makeRepoWithWorktree(): Promise<Handle> {const worktree = join(root, 'wt', 'feature');mkdirSync(join(root, 'wt'), { recursive: true });await git(mainRepo, 'worktree', 'add', '-b', 'feature', worktree);+ configureTestGitRepository(worktree);return {root,mainRepo,diff --git a/packages/desktop/src/main/worktree-service.test.ts b/packages/desktop/src/main/worktree-service.test.tsindex f58e0b9ba..a8d27b705 100644--- a/packages/desktop/src/main/worktree-service.test.ts+++ b/packages/desktop/src/main/worktree-service.test.ts@@ -16,6 +16,7 @@ import { promisify } from 'node:util';import { addOkPathsToGitExclude, getOkArtifactPaths } from '@inkeep/open-knowledge';import { initContent } from '@inkeep/open-knowledge-server';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { discoverProject } from './folder-admission.ts';import { clearRecentGitCache } from './worktree-recents.ts';import {@@ -45,6 +46,7 @@ async function makeRepo(extraBranches: string[] = []): Promise<Handle> {const mainRepo = join(root, 'main');mkdirSync(mainRepo);await git(mainRepo, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(mainRepo);await git(mainRepo, 'config', 'user.email', '[email protected]');await git(mainRepo, 'config', 'user.name', 'Test');mkdirSync(join(mainRepo, '.ok'));@@ -59,6 +61,7 @@ async function makeRepo(extraBranches: string[] = []): Promise<Handle> {async function addBareRemote(mainRepo: string, pushBranches: string[]): Promise<string> {const bare = join(mainRepo, '..', 'origin.git');await git(mainRepo, 'init', '--bare', '--initial-branch=main', bare);+ configureTestGitRepository(bare);await git(mainRepo, 'remote', 'add', 'origin', bare);for (const b of pushBranches) await git(mainRepo, 'push', 'origin', b);await git(mainRepo, 'fetch', 'origin');@@ -198,6 +201,7 @@ describe('worktree-service', () => {const root = realpathSync(mkdtempSync(join(tmpdir(), 'wt-svc-empty-')));try {await git(root, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(root);const res = await createWorktree({anchorPath: root,branch: 'wt-1',@@ -230,6 +234,7 @@ describe('worktree-service', () => {const root = realpathSync(mkdtempSync(join(tmpdir(), 'wt-svc-other-branch-')));try {await git(root, 'init', '--initial-branch=other', '.');+ configureTestGitRepository(root);await git(root, 'config', 'user.email', '[email protected]');await git(root, 'config', 'user.name', 'Test');await git(root, 'commit', '--allow-empty', '-m', 'real history');@@ -427,6 +432,7 @@ describe('worktree-service', () => {await addBareRemote(handle.mainRepo, ['main', 'dev']);const scratch = join(handle.root, 'scratch');await git(handle.root, 'clone', join(handle.mainRepo, '..', 'origin.git'), scratch);+ configureTestGitRepository(scratch);await git(scratch, 'config', 'user.email', '[email protected]');await git(scratch, 'config', 'user.name', 'Test');writeFileSync(join(scratch, 'a.txt'), 'a\n');@@ -451,6 +457,7 @@ describe('worktree-service', () => {await addBareRemote(handle.mainRepo, ['main']);const scratch = join(handle.root, 'scratch');await git(handle.root, 'clone', join(handle.mainRepo, '..', 'origin.git'), scratch);+ configureTestGitRepository(scratch);await git(scratch, 'config', 'user.email', '[email protected]');await git(scratch, 'config', 'user.name', 'Test');await git(scratch, 'checkout', '-b', 'feature-x');@@ -489,6 +496,7 @@ describe('worktree-service', () => {await addBareRemote(handle.mainRepo, ['main']);const scratch = join(handle.root, 'scratch');await git(handle.root, 'clone', join(handle.mainRepo, '..', 'origin.git'), scratch);+ configureTestGitRepository(scratch);await git(scratch, 'config', 'user.email', '[email protected]');await git(scratch, 'config', 'user.name', 'Test');writeFileSync(join(scratch, 'fresh.txt'), 'fresh from origin\n');@@ -599,6 +607,7 @@ describe('worktree-service — share-branch checkout', () => {await addBareRemote(handle.mainRepo, ['main']);const scratch = join(handle.root, 'scratch');await git(handle.root, 'clone', join(handle.mainRepo, '..', 'origin.git'), scratch);+ configureTestGitRepository(scratch);await git(scratch, 'config', 'user.email', '[email protected]');await git(scratch, 'config', 'user.name', 'Test');await git(scratch, 'checkout', '-b', 'never-fetched');@@ -666,6 +675,7 @@ describe('worktree-service — share-branch checkout', () => {): Promise<string> {const scratch = join(root, `scratch-${branch}`);await git(root, 'clone', join(root, 'origin.git'), scratch);+ configureTestGitRepository(scratch);await git(scratch, 'config', 'user.email', '[email protected]');await git(scratch, 'config', 'user.name', 'Test');await git(scratch, 'checkout', '-b', branch);@@ -874,6 +884,7 @@ async function makeLocalOnlyRepo(): Promise<Handle> {const mainRepo = join(root, 'main');mkdirSync(mainRepo);await git(mainRepo, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(mainRepo);await git(mainRepo, 'config', 'user.email', '[email protected]');await git(mainRepo, 'config', 'user.name', 'Test');writeFileSync(join(mainRepo, 'README.md'), '# main\n');@@ -909,6 +920,7 @@ describe('worktree-service — inherited OK setup (no consent dialog)', () => {cwd: handle.mainRepo,env: GIT_ENV,});+ configureTestGitRepository(wtPath);expect(existsSync(join(wtPath, '.ok', 'config.yml'))).toBe(false);const before = await discoverProject(wtPath, { homeDir: handle.root, dirSizeProbe: null });@@ -931,6 +943,7 @@ describe('worktree-service — inherited OK setup (no consent dialog)', () => {cwd: handle.mainRepo,env: GIT_ENV,});+ configureTestGitRepository(wtPath);seedWorktreeProjectSetup(wtPath, handle.mainRepo);diff --git a/packages/desktop/tests/integration/detached-lifecycle.test.ts b/packages/desktop/tests/integration/detached-lifecycle.test.tsindex a9bb6e200..9f424767a 100644--- a/packages/desktop/tests/integration/detached-lifecycle.test.ts+++ b/packages/desktop/tests/integration/detached-lifecycle.test.ts@@ -13,6 +13,7 @@ import {createServerExitRecorder,type ServerExitRecord,} from '../../src/main/server-exit-record.ts';+import { configureProjectGitRepositories } from '../support/git-fixture.test-helper.ts';const HERE = dirname(fileURLToPath(import.meta.url));const CLI_MJS_PATH = resolve(HERE, '../../../cli/dist/cli.mjs');@@ -110,6 +111,8 @@ describe('detached-server lifecycle integration', () => {if (pgid !== null && myPgid !== null) {expect(pgid).not.toBe(myPgid);}++ await configureProjectGitRepositories(tmpDir, `http://127.0.0.1:${lock.port}`);} finally {child.kill('SIGKILL');await wait(200);diff --git a/packages/desktop/tests/integration/ephemeral-lifecycle.test.ts b/packages/desktop/tests/integration/ephemeral-lifecycle.test.tsindex 8e5cd6011..8827c4189 100644--- a/packages/desktop/tests/integration/ephemeral-lifecycle.test.ts+++ b/packages/desktop/tests/integration/ephemeral-lifecycle.test.ts@@ -8,6 +8,7 @@ import { setTimeout as wait } from 'node:timers/promises';import { fileURLToPath } from 'node:url';import { createEphemeralProjectDir, isProcessAlive } from '@inkeep/open-knowledge-server';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureProjectGitRepositories } from '../support/git-fixture.test-helper.ts';const HERE = dirname(fileURLToPath(import.meta.url));const CLI_MJS_PATH = resolve(HERE, '../../../cli/dist/cli.mjs');@@ -119,6 +120,8 @@ describe('ephemeral single-file lifecycle (real CLI)', () => {const config = (await res.json()) as { singleFile?: boolean };expect(config.singleFile).toBe(true);+ await configureProjectGitRepositories(tempProjectDir, `http://127.0.0.1:${lock.port}`);+child.kill('SIGTERM');const releaseDeadline = Date.now() + LOCK_POLL_TIMEOUT_MS;let released = false;diff --git a/packages/desktop/tests/smoke/_helpers/project-editor-window.ts b/packages/desktop/tests/smoke/_helpers/project-editor-window.tsnew file mode 100644index 000000000..7a3af2d08--- /dev/null+++ b/packages/desktop/tests/smoke/_helpers/project-editor-window.ts@@ -0,0 +1,34 @@+import { realpathSync } from 'node:fs';+import type { ElectronApplication, Page } from '@playwright/test';++function canonicalPathIfPresent(path: string): string | undefined {+ try {+ return realpathSync(path);+ } catch (error) {+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;+ throw error;+ }+}++export async function findProjectEditorWindow(+ app: ElectronApplication,+ projectDir: string,+): Promise<Page | undefined> {+ const canonicalProjectDir = realpathSync(projectDir);+ for (const page of app.windows()) {+ const editorProjectPath = await page+ .evaluate(() =>+ window.okDesktop?.config?.mode === 'editor'+ ? window.okDesktop.config.projectPath+ : undefined,+ )+ .catch(() => undefined);+ if (+ editorProjectPath !== undefined &&+ canonicalPathIfPresent(editorProjectPath) === canonicalProjectDir+ ) {+ return page;+ }+ }+ return undefined;+}diff --git a/packages/desktop/tests/smoke/_helpers/settings-surface.ts b/packages/desktop/tests/smoke/_helpers/settings-surface.tsindex 5f55b8569..94197cfa8 100644--- a/packages/desktop/tests/smoke/_helpers/settings-surface.ts+++ b/packages/desktop/tests/smoke/_helpers/settings-surface.ts@@ -11,10 +11,12 @@ import {import { tmpdir } from 'node:os';import { join } from 'node:path';import { type ElectronApplication, _electron as electron, type Page } from '@playwright/test';+import { configureDesktopGitRepositories } from '../../support/git-fixture.test-helper.ts';import { captureAppProcess, closeAppBounded } from './electron-cleanup';import { type DesktopTarget, desktopLaunchOptions, resolveDesktopTarget } from './launch-desktop';import { seedMcpConsentComplete } from './mcp-consent';import { homeEnv, userDataDirFor } from './platform-gate';+import { findProjectEditorWindow } from './project-editor-window';import { expect } from './smoke-test';export interface SeededProjectProfile {@@ -144,6 +146,7 @@ export async function openSpellingSettings(): Promise<SpellingSettingsSession> {const app = await launchOnSeededProfile(profile, options);const editor = await findEditorWindow(app);+ await configureDesktopGitRepositories(editor, profile.projectDir);await options.beforeSettings?.(app, editor);await openSettingsDialog(editor);await showUserPreferences(editor);@@ -239,29 +242,18 @@ export async function findEditorWindowForProject(projectPath: string,timeoutMs = 45_000,): Promise<Page> {- const readProject = (page: Page): Promise<string | undefined> =>- page- .evaluate(() =>- window.okDesktop?.config?.mode === 'editor'- ? window.okDesktop.config.projectPath- : undefined,- )- .catch(() => undefined);await expect- .poll(- async () => {- for (const page of app.windows()) {- if ((await readProject(page)) === projectPath) return true;- }- return false;- },- { timeout: timeoutMs, message: `no editor window opened on ${projectPath}` },- )+ .poll(async () => (await findProjectEditorWindow(app, projectPath)) !== undefined, {+ timeout: timeoutMs,+ message: `no editor window opened on ${projectPath}`,+ }).toBe(true);- for (const page of app.windows()) {- if ((await readProject(page)) === projectPath) return page;+ const page = await findProjectEditorWindow(app, projectPath);+ if (page === undefined) {+ throw new Error(`the window on ${projectPath} vanished between poll resolution and read`);}- throw new Error(`the window on ${projectPath} vanished between poll resolution and read`);+ await configureDesktopGitRepositories(page, projectPath);+ return page;}export async function openProjectFromRecents(editor: Page, projectPath: string): Promise<void> {diff --git a/packages/desktop/tests/smoke/_nav-size-screenshots.e2e.ts b/packages/desktop/tests/smoke/_nav-size-screenshots.e2e.tsindex 73e053b73..19e525c5e 100644--- a/packages/desktop/tests/smoke/_nav-size-screenshots.e2e.ts+++ b/packages/desktop/tests/smoke/_nav-size-screenshots.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import type { ElectronApplication, JSHandle, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import {DESKTOP_ROOT,desktopLaunchOptions,@@ -129,6 +130,7 @@ test.describe('Navigator size screenshots (dev-only)', () => {captureStderrFor(app, { home: tmpHome });const editor = await findWindow(app, 'editor');+ await configureDesktopGitRepositories(editor, projectDir);await editor.evaluate(async () => {await window.okDesktop?.navigator.open();});diff --git a/packages/desktop/tests/smoke/agent-patch-divergence-probe.e2e.ts b/packages/desktop/tests/smoke/agent-patch-divergence-probe.e2e.tsindex 433198044..668d0b50e 100644--- a/packages/desktop/tests/smoke/agent-patch-divergence-probe.e2e.ts+++ b/packages/desktop/tests/smoke/agent-patch-divergence-probe.e2e.ts@@ -5,10 +5,11 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';import { type ElectronApplication, _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { PLATFORM_SKIP_REASON, PLATFORM_SUPPORTED, SMOKE_ENABLED } from './_helpers/platform-gate';import { waitForEditorSelection } from './_helpers/settings-surface';-import { expect, test } from './_helpers/smoke-test';+import { expect, type SmokeFixtures, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -300,7 +301,7 @@ async function executeRace(opts: {async function setupElectron(variantTag: string,- captureStderrFor: (app: ElectronApplication) => void,+ captureStderrFor: SmokeFixtures['captureStderrFor'],): Promise<{app: ElectronApplication;page: import('@playwright/test').Page;@@ -338,7 +339,7 @@ async function setupElectron(timeout: 30_000,}),);- captureStderrFor(app);+ captureStderrFor(app, { cleanupDirs: [contentDir, userDataDir] });const expectedHashSuffix = `#/${docName}`;let page: import('@playwright/test').Page | undefined;@@ -357,6 +358,7 @@ async function setupElectron(await expect(page.locator('.ProseMirror[contenteditable="true"]:not(.composer-prosemirror)'),).toContainText(AGENT_FIND, { timeout: 30_000 });+ await configureDesktopGitRepositories(page, contentDir);const { port } = await detectApiPort(page);diff --git a/packages/desktop/tests/smoke/background-throttle.e2e.ts b/packages/desktop/tests/smoke/background-throttle.e2e.tsindex d5775412e..daaa8ecc2 100644--- a/packages/desktop/tests/smoke/background-throttle.e2e.ts+++ b/packages/desktop/tests/smoke/background-throttle.e2e.ts@@ -4,6 +4,7 @@ import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import type { ElectronApplication, JSHandle, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import {homeEnv,PLATFORM_SKIP_REASON,@@ -160,6 +161,7 @@ test.describe('background-throttle smoke', () => {message: 'baseline: expected the OS default (backgroundThrottling === true)',}).toBe(true);+ await configureDesktopGitRepositories(editor, projectDir);await pushAndExpectThrottling(app,diff --git a/packages/desktop/tests/smoke/cold-single-file-launch.e2e.ts b/packages/desktop/tests/smoke/cold-single-file-launch.e2e.tsindex 229062387..bca16b819 100644--- a/packages/desktop/tests/smoke/cold-single-file-launch.e2e.ts+++ b/packages/desktop/tests/smoke/cold-single-file-launch.e2e.ts@@ -10,8 +10,13 @@ import {writeFileSync,} from 'node:fs';import { tmpdir } from 'node:os';-import { basename, join } from 'node:path';+import { basename, dirname, join } from 'node:path';import { expect, test } from '@playwright/test';+import {+ configureEphemeralGitRepositories,+ configureProjectGitRepositories,+ readTestServerRepository,+} from '../support/git-fixture.test-helper';import { resolveDesktopTarget } from './_helpers/launch-desktop';const TARGET = resolveDesktopTarget({ requirePackaged: true });@@ -91,7 +96,10 @@ function readLogLinesSince(sinceMs: number): Array<Record<string, unknown>> {);}-async function waitForBootDecision(sinceMs: number): Promise<BootRestoreDecisionLog> {+async function waitForBootDecision(+ sinceMs: number,+ observeServer?: () => void,+): Promise<BootRestoreDecisionLog> {let found: Record<string, unknown> | undefined;await expect(() => {found = readLogLinesSince(sinceMs).find((e) => e.msg === 'boot-restore decision');@@ -99,10 +107,27 @@ async function waitForBootDecision(sinceMs: number): Promise<BootRestoreDecisionfound,`no boot-restore decision logged since ${new Date(sinceMs).toISOString()}`,).toBeDefined();+ observeServer?.();}).toPass({ timeout: 60_000, intervals: [500] });return found as unknown as BootRestoreDecisionLog;}+function readEphemeralServerLog(sinceMs: number, file: string): { lockDir: string; port: number } {+ const matches = readLogLinesSince(sinceMs).filter(+ (entry) => entry.event === 'desktop-ephemeral-server-spawned' && entry.file === file,+ );+ const entry = matches[0];+ if (+ matches.length !== 1 ||+ !entry ||+ typeof entry.lockDir !== 'string' ||+ typeof entry.port !== 'number'+ ) {+ throw new Error(`Expected one ephemeral server log for ${file}`);+ }+ return { lockDir: entry.lockDir, port: entry.port };+}+function launchViaLaunchServices(target: string): number {const since = Date.now();execFileSync('open', ['-a', TARGET.appPath as string, target], { stdio: 'pipe' });@@ -112,7 +137,14 @@ function launchViaLaunchServices(target: string): number {async function establishRestoreSnapshot(projectFile: string): Promise<void> {quitAppCleanly();const since = launchViaLaunchServices(projectFile);- await waitForBootDecision(since);+ const projectDir = dirname(projectFile);+ const lockDir = join(projectDir, '.ok', 'local');+ await waitForBootDecision(since, () => {+ expect(readTestServerRepository(lockDir).projectDir).toBe(projectDir);+ });+ const server = readTestServerRepository(lockDir);+ expect(server.projectDir).toBe(projectDir);+ await configureProjectGitRepositories(projectDir, server.apiOrigin);execFileSync('sleep', ['6']);quitAppCleanly();}@@ -136,7 +168,10 @@ test.describe('cold launch with an explicit target owns the initial window set',await establishRestoreSnapshot(project.file);const since = launchViaLaunchServices(loose.file);- const decision = await waitForBootDecision(since);+ const decision = await waitForBootDecision(since, () => {+ const spawned = readEphemeralServerLog(since, loose.file);+ expect(readTestServerRepository(spawned.lockDir).port).toBe(spawned.port);+ });expect(decision.snapshotWindowCount,@@ -144,6 +179,11 @@ test.describe('cold launch with an explicit target owns the initial window set',).toBeGreaterThanOrEqual(1);expect(decision.urlLaunch).toBe(true);expect(decision.action).toBe('none');++ const spawned = readEphemeralServerLog(since, loose.file);+ const server = readTestServerRepository(spawned.lockDir);+ expect(server.port).toBe(spawned.port);+ await configureEphemeralGitRepositories(server.projectDir, server.apiOrigin);} finally {quitAppCleanly();rmSync(project.dir, { recursive: true, force: true });diff --git a/packages/desktop/tests/smoke/consent-dialog.e2e.ts b/packages/desktop/tests/smoke/consent-dialog.e2e.tsindex 81c6f9f0b..857a48e9d 100644--- a/packages/desktop/tests/smoke/consent-dialog.e2e.ts+++ b/packages/desktop/tests/smoke/consent-dialog.e2e.ts@@ -12,6 +12,8 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { reapDetachedServers } from './_helpers/electron-cleanup';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { launchDesktopApp, waitForWindowByMode } from './_helpers/launch-readiness';@@ -59,6 +61,7 @@ function seedGitRepoWithSubFolder(const repoRoot = join(tmpHome, `ok-consent-${prefix}-git`);mkdirSync(repoRoot, { recursive: true });execSync('git init -q', { cwd: repoRoot });+ configureTestGitRepository(repoRoot);const subFolder = join(repoRoot, 'docs');mkdirSync(subFolder, { recursive: true });return { repoRoot, subFolder };@@ -146,10 +149,11 @@ test.describe('Consent-dialog smoke', () => {await contentDir.focus();await contentDir.press('Enter');- await findWindowByMode(app, 'editor');+ const editor = await findWindowByMode(app, 'editor');await expect.poll(() => existsSync(join(projectDir, '.ok', 'config.yml')), { timeout: 15_000 }).toBe(true);+ await configureDesktopGitRepositories(editor, projectDir);});test('Browse button populates content.dir with project-relative path', async ({@@ -200,7 +204,7 @@ test.describe('Consent-dialog smoke', () => {const startBtn = navigator.locator('[data-testid="consent-start"]');await startBtn.click();- await findWindowByMode(app, 'editor');+ const editor = await findWindowByMode(app, 'editor');await expect.poll(() => existsSync(join(repoRoot, '.ok', 'config.yml')), { timeout: 15_000 }).toBe(true);@@ -209,5 +213,6 @@ test.describe('Consent-dialog smoke', () => {const cfg = readFileSync(join(repoRoot, '.ok', 'config.yml'), 'utf8');expect(cfg).not.toMatch(/^\s*dir:\s*docs/m);expect(cfg).toMatch(/^# content:/m);+ await configureDesktopGitRepositories(editor, repoRoot);});});diff --git a/packages/desktop/tests/smoke/create-new-project.e2e.ts b/packages/desktop/tests/smoke/create-new-project.e2e.tsindex c540c2127..36415756f 100644--- a/packages/desktop/tests/smoke/create-new-project.e2e.ts+++ b/packages/desktop/tests/smoke/create-new-project.e2e.ts@@ -12,6 +12,8 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { typeProjectName } from './_helpers/create-new-dialog';import { reapDetachedServers } from './_helpers/electron-cleanup';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';@@ -23,6 +25,7 @@ import {PLATFORM_SUPPORTED,SMOKE_ENABLED,} from './_helpers/platform-gate';+import { findProjectEditorWindow } from './_helpers/project-editor-window';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -187,6 +190,7 @@ test.describe('Create-new-project smoke', () => {if (!editor) throw new Error('editor window not found after create-new submit');const freshlyCreated = await editor.evaluate(() => window.okDesktop?.config?.freshlyCreated);expect(freshlyCreated).toBe(true);+ await configureDesktopGitRepositories(editor, expectedTarget);});test('blocks creation when chosen Location is inside an existing OK project', async ({@@ -232,6 +236,7 @@ test.describe('Create-new-project smoke', () => {const repoRoot = join(tmpHome, 'website');mkdirSync(repoRoot, { recursive: true });execSync('git init -q', { cwd: repoRoot });+ configureTestGitRepository(repoRoot);const pickedParent = join(repoRoot, 'notes');mkdirSync(pickedParent, { recursive: true });const projectName = 'MyProj';@@ -278,6 +283,9 @@ test.describe('Create-new-project smoke', () => {const cfg = readFileSync(join(repoRoot, '.ok', 'config.yml'), 'utf8');expect(cfg).not.toMatch(/^\s*dir:\s*notes\/MyProj/m);expect(cfg).toMatch(/^# content:/m);+ const editor = await findProjectEditorWindow(app, repoRoot);+ if (!editor) throw new Error('editor window not found after existing-repo promotion');+ await configureDesktopGitRepositories(editor, repoRoot);});test('PRD-6649: cascade banner DOM node survives a verdict-content change of the same kind (no flicker, real Electron renderer)', async ({@@ -383,6 +391,7 @@ test.describe('Create-new-project smoke', () => {const repoRoot = join(tmpHome, 'some-checkout');mkdirSync(repoRoot, { recursive: true });execSync('git init -q', { cwd: repoRoot });+ configureTestGitRepository(repoRoot);const pickedParent = join(repoRoot, 'docs');mkdirSync(pickedParent, { recursive: true });trackForCleanup(tmpHome);diff --git a/packages/desktop/tests/smoke/deep-link.e2e.ts b/packages/desktop/tests/smoke/deep-link.e2e.tsindex f9b765f6f..f428db808 100644--- a/packages/desktop/tests/smoke/deep-link.e2e.ts+++ b/packages/desktop/tests/smoke/deep-link.e2e.ts@@ -2,7 +2,8 @@ import { execSync } from 'node:child_process';import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { _electron as electron } from '@playwright/test';+import { _electron as electron, type Page } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { expect, test } from './_helpers/smoke-test';@@ -47,13 +48,19 @@ test.describe('deep-link warm-start smoke (M4 US-009 / AC7)', () => {const deepLink = `openknowledge://open?project=${encodeURIComponent(projectDir)}&doc=target`;execSync(`open -g "${deepLink}"`, { stdio: 'pipe' });+ let editorPage: Page | undefined;await expect(async () => {for (const page of app.windows()) {const hash = await page.evaluate(() => window.location.hash).catch(() => '');- if (hash.endsWith('#/target')) return;+ if (hash.endsWith('#/target')) {+ editorPage = page;+ return;+ }}throw new Error('no window has hash matching the extension-less producer form yet');}).toPass({ timeout: 15_000 });+ if (!editorPage) throw new Error('matching editor window vanished');+ await configureDesktopGitRepositories(editorPage, projectDir);});test('open(1) shell-out with nested docName round-trips encoded slash', async ({@@ -87,12 +94,18 @@ test.describe('deep-link warm-start smoke (M4 US-009 / AC7)', () => {const deepLink = `openknowledge://open?project=${encodeURIComponent(projectDir)}&doc=notes%2Fmeeting`;execSync(`open -g "${deepLink}"`, { stdio: 'pipe' });+ let editorPage: Page | undefined;await expect(async () => {for (const page of app.windows()) {const hash = await page.evaluate(() => window.location.hash).catch(() => '');- if (hash === '#/notes%2Fmeeting' || hash === '#/notes/meeting') return;+ if (hash === '#/notes%2Fmeeting' || hash === '#/notes/meeting') {+ editorPage = page;+ return;+ }}throw new Error('no window has nested-doc hash yet');}).toPass({ timeout: 15_000 });+ if (!editorPage) throw new Error('matching editor window vanished');+ await configureDesktopGitRepositories(editorPage, projectDir);});});diff --git a/packages/desktop/tests/smoke/external-link.e2e.ts b/packages/desktop/tests/smoke/external-link.e2e.tsindex 0130cc1b5..8f205d2be 100644--- a/packages/desktop/tests/smoke/external-link.e2e.ts+++ b/packages/desktop/tests/smoke/external-link.e2e.ts@@ -2,6 +2,7 @@ import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { expect, test } from './_helpers/smoke-test';@@ -72,6 +73,7 @@ test.describe('external-link safety-net delegation', () => {}).toPass({ timeout: 15_000 });if (!editorPage) throw new Error('unreachable');+ await configureDesktopGitRepositories(editorPage, projectDir);await editorPage.evaluate(() => {window.open('https://github.com/inkeep/open-knowledge', '_blank', 'noopener,noreferrer');diff --git a/packages/desktop/tests/smoke/mcp-wiring.e2e.ts b/packages/desktop/tests/smoke/mcp-wiring.e2e.tsindex 1801ff5ea..8c6d08031 100644--- a/packages/desktop/tests/smoke/mcp-wiring.e2e.ts+++ b/packages/desktop/tests/smoke/mcp-wiring.e2e.ts@@ -11,6 +11,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {homeEnv,@@ -18,6 +19,7 @@ import {PLATFORM_SUPPORTED,SMOKE_ENABLED,} from './_helpers/platform-gate';+import { findProjectEditorWindow } from './_helpers/project-editor-window';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -365,6 +367,9 @@ test.describe('M6b first-launch MCP-wiring smoke (US-010)', () => {const marker = readMarker(tmpHome);expect(marker).toMatchObject({ configured: true });+ const editor = await findProjectEditorWindow(app, projectDir);+ if (!editor) throw new Error('expected project editor did not open');+ await configureDesktopGitRepositories(editor, projectDir);} finally {forceRemove([], tmpHome);}diff --git a/packages/desktop/tests/smoke/navigator-close-on-open.e2e.ts b/packages/desktop/tests/smoke/navigator-close-on-open.e2e.tsindex 61ca11fe9..f09eb8609 100644--- a/packages/desktop/tests/smoke/navigator-close-on-open.e2e.ts+++ b/packages/desktop/tests/smoke/navigator-close-on-open.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {homeEnv,@@ -10,6 +11,7 @@ import {PLATFORM_SUPPORTED,SMOKE_ENABLED,} from './_helpers/platform-gate';+import { findProjectEditorWindow } from './_helpers/project-editor-window';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -168,6 +170,8 @@ test.describe('Project Navigator close-on-project-open smoke', () => {expect(await countWindowsByMode(app, 'editor')).toBe(1);expect(await countWindowsByMode(app, 'navigator')).toBe(0);+ const editor = await findFirstWindowByMode(app, 'editor');+ await configureDesktopGitRepositories(editor, projectDir);});test('Switch-Project flow: Editor A summons Navigator, picks Project B, both editors persist', async ({@@ -185,6 +189,7 @@ test.describe('Project Navigator close-on-project-open smoke', () => {.toBe(1);const editorA = await findFirstWindowByMode(app, 'editor');expect(await countWindowsByMode(app, 'navigator')).toBe(0);+ await configureDesktopGitRepositories(editorA, projectAPath);await editorA.evaluate(async () => {await window.okDesktop?.navigator.open();@@ -217,6 +222,9 @@ test.describe('Project Navigator close-on-project-open smoke', () => {expect(editorA.isClosed()).toBe(false);expect(await countWindowsByMode(app, 'editor')).toBe(2);+ const editorB = await findProjectEditorWindow(app, projectBPath);+ if (!editorB) throw new Error('Project B editor did not open');+ await configureDesktopGitRepositories(editorB, projectBPath);});test('Navigator stays visible when project open fails', async ({ captureStderrFor }) => {diff --git a/packages/desktop/tests/smoke/navigator-return.e2e.ts b/packages/desktop/tests/smoke/navigator-return.e2e.tsindex 2a4e1349c..b8fed8172 100644--- a/packages/desktop/tests/smoke/navigator-return.e2e.ts+++ b/packages/desktop/tests/smoke/navigator-return.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {homeEnv,@@ -144,6 +145,7 @@ test.describe('Project Navigator return-affordance smoke', () => {const editor = await findEditorWindow(app);await expect.poll(() => countNavigatorWindows(app)).toBe(0);+ await configureDesktopGitRepositories(editor, projectDir);await editor.evaluate(async () => {await window.okDesktop?.navigator.open();@@ -180,6 +182,7 @@ test.describe('Project Navigator return-affordance smoke', () => {const editor = await findEditorWindow(app);await expect.poll(() => countEditorWindows(app)).toBe(1);+ await configureDesktopGitRepositories(editor, projectDir);await editor.evaluate(async () => {await window.okDesktop?.navigator.open();diff --git a/packages/desktop/tests/smoke/note-window.e2e.ts b/packages/desktop/tests/smoke/note-window.e2e.tsindex 20e47f853..02f98e62f 100644--- a/packages/desktop/tests/smoke/note-window.e2e.ts+++ b/packages/desktop/tests/smoke/note-window.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {homeEnv,@@ -176,6 +177,7 @@ test.describe('Popped-out note window — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const editor = await findWindowByMode(app, 'editor');+ await configureDesktopGitRepositories(editor, s.projectDir);await openDocument(editor, 'start');await popOutFrom(app, editor);@@ -229,6 +231,7 @@ test.describe('Popped-out note window — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const editor = await findWindowByMode(app, 'editor');+ await configureDesktopGitRepositories(editor, s.projectDir);await openDocument(editor, 'start');await popOutFrom(app, editor);@@ -290,6 +293,7 @@ test.describe('Popped-out note window — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const editor = await findWindowByMode(app, 'editor');+ await configureDesktopGitRepositories(editor, s.projectDir);await openDocument(editor, 'start');await popOutFrom(app, editor);@@ -313,6 +317,7 @@ test.describe('Popped-out note window — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const editor = await findWindowByMode(app, 'editor');+ await configureDesktopGitRepositories(editor, s.projectDir);await openDocument(editor, 'start');await popOutFrom(app, editor);@@ -331,6 +336,7 @@ test.describe('Popped-out note window — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const editor = await findWindowByMode(app, 'editor');+ await configureDesktopGitRepositories(editor, s.projectDir);await openDocument(editor, 'start');await popOutFrom(app, editor);@@ -369,6 +375,7 @@ test.describe('Popped-out note window — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const editor = await findWindowByMode(app, 'editor');+ await configureDesktopGitRepositories(editor, s.projectDir);await openDocument(editor, 'start');await popOutFrom(app, editor);@@ -394,6 +401,7 @@ test.describe('Popped-out note window — live Electron', () => {const first = await launchApp(s);captureStderrFor(first, { home: s.tmpHome, cleanupDirs: [] });const editor = await findWindowByMode(first, 'editor');+ await configureDesktopGitRepositories(editor, s.projectDir);await openDocument(editor, 'start');await popOutFrom(first, editor);await findWindowByMode(first, 'note');diff --git a/packages/desktop/tests/smoke/okf-rule-toggle.e2e.ts b/packages/desktop/tests/smoke/okf-rule-toggle.e2e.tsindex a4eb95c8d..5a671e9d4 100644--- a/packages/desktop/tests/smoke/okf-rule-toggle.e2e.ts+++ b/packages/desktop/tests/smoke/okf-rule-toggle.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { expect, test } from './_helpers/smoke-test';const __dirname = dirname(fileURLToPath(import.meta.url));@@ -54,6 +55,7 @@ test.describe('okf per-rule toggle round-trip', () => {}throw new Error('project window never mounted from the argv deep-link');})();+ await configureDesktopGitRepositories(settingsPage, projectDir);await settingsPage.getByTestId('header-settings-button').click({ timeout: 15_000 });await settingsPage.getByTestId('settings-sidebar-item-plugin:okf').click({ timeout: 15_000 });diff --git a/packages/desktop/tests/smoke/qa-create-new-extended.e2e.ts b/packages/desktop/tests/smoke/qa-create-new-extended.e2e.tsindex 148046a43..d86ba1a14 100644--- a/packages/desktop/tests/smoke/qa-create-new-extended.e2e.ts+++ b/packages/desktop/tests/smoke/qa-create-new-extended.e2e.ts@@ -12,6 +12,8 @@ import { tmpdir } from 'node:os';import { delimiter, join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { typeProjectName } from './_helpers/create-new-dialog';import { captureAppProcess, closeAppBounded } from './_helpers/electron-cleanup';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';@@ -22,6 +24,7 @@ import {PLATFORM_SUPPORTED,SMOKE_ENABLED,} from './_helpers/platform-gate';+import { findProjectEditorWindow } from './_helpers/project-editor-window';import { expect, test } from './_helpers/smoke-test';const TARGET = resolveDesktopTarget();@@ -123,6 +126,12 @@ async function countWindowsByMode(return n;}+async function findProjectEditor(app: ElectronApplication, projectDir: string): Promise<Page> {+ const editor = await findProjectEditorWindow(app, projectDir);+ if (!editor) throw new Error(`editor window not found for ${projectDir}`);+ return editor;+}+const cleanupTargets: string[] = [];function trackForCleanup(...paths: string[]): void {cleanupTargets.push(...paths);@@ -199,6 +208,7 @@ test.describe('QA extended create-new-project', () => {expect(existsSync(join(expected, '.codex'))).toBe(false);expect(existsSync(join(expected, '.claude'))).toBe(false);expect(existsSync(join(expected, '.mcp.json'))).toBe(false);+ await configureDesktopGitRepositories(await findProjectEditor(app, expected), expected);});test('QA-010 dialog UX — focus, location, checkboxes, ARIA', async ({ captureStderrFor }) => {@@ -292,6 +302,10 @@ test.describe('QA extended create-new-project', () => {.toBe(true);expect(existsSync(join(firstProject, '.cursor'))).toBe(false);expect(existsSync(join(firstProject, '.mcp.json'))).toBe(false);+ await configureDesktopGitRepositories(+ await findProjectEditor(app1, firstProject),+ firstProject,+ );await closeAppBounded(app1Proc, { gracefulMs: 5_000 }).catch((error: unknown) => {throw new Error(@@ -419,6 +433,8 @@ test.describe('QA extended create-new-project', () => {const editorCount = await countWindowsByMode(app, 'editor');expect(editorCount).toBe(1);expect(existsSync(join(parent, projectName, '.ok', 'config.yml'))).toBe(true);+ const projectDir = join(parent, projectName);+ await configureDesktopGitRepositories(await findProjectEditor(app, projectDir), projectDir);});test('QA-025 — banner ARIA roles per severity', async ({ captureStderrFor }) => {@@ -459,6 +475,7 @@ test.describe('QA extended create-new-project', () => {const repoRoot = join(tmpHome, 'website');mkdirSync(repoRoot, { recursive: true });execSync('git init -q', { cwd: repoRoot });+ configureTestGitRepository(repoRoot);const pickedParent = join(repoRoot, 'notes');mkdirSync(pickedParent, { recursive: true });const projectName = 'MyProj';@@ -519,6 +536,8 @@ test.describe('QA extended create-new-project', () => {.poll(() => countWindowsByMode(app, 'editor'), { timeout: 30_000 }).toBeGreaterThanOrEqual(1);expect(existsSync(join(parent, projectName, '.ok', 'config.yml'))).toBe(true);+ const projectDir = join(parent, projectName);+ await configureDesktopGitRepositories(await findProjectEditor(app, projectDir), projectDir);});test('QA-002 — clicking Open <basename> dispatches openProject and closes dialog', async ({diff --git a/packages/desktop/tests/smoke/rename-divergence-probe.e2e.ts b/packages/desktop/tests/smoke/rename-divergence-probe.e2e.tsindex 42e5eac61..f31115f34 100644--- a/packages/desktop/tests/smoke/rename-divergence-probe.e2e.ts+++ b/packages/desktop/tests/smoke/rename-divergence-probe.e2e.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';import { type ElectronApplication, _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { PLATFORM_SKIP_REASON, PLATFORM_SUPPORTED, SMOKE_ENABLED } from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';@@ -77,6 +78,7 @@ async function runProbe(await expect(page.locator('.ProseMirror[contenteditable="true"]:not(.composer-prosemirror)'),).toContainText(marker, { timeout: 30_000 });+ await configureDesktopGitRepositories(page, contentDir);const apiOrigin = await page.evaluate(() => window.okDesktop?.config?.apiOrigin);if (!apiOrigin) {diff --git a/packages/desktop/tests/smoke/report-bug.e2e.ts b/packages/desktop/tests/smoke/report-bug.e2e.tsindex d5342a549..8c2565363 100644--- a/packages/desktop/tests/smoke/report-bug.e2e.ts+++ b/packages/desktop/tests/smoke/report-bug.e2e.ts@@ -10,6 +10,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Locator, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {homeEnv,@@ -77,6 +78,7 @@ async function bootEditorWindow(await expect(page.getByTestId('sidebar-toolbar').getByRole('button', { name: 'New file' }),).toBeVisible({ timeout: 30_000 });+ await configureDesktopGitRepositories(page, projectDir);return { app, page, tmpHome };}diff --git a/packages/desktop/tests/smoke/saved-theme-paint.e2e.ts b/packages/desktop/tests/smoke/saved-theme-paint.e2e.tsindex 985261c16..f15a65351 100644--- a/packages/desktop/tests/smoke/saved-theme-paint.e2e.ts+++ b/packages/desktop/tests/smoke/saved-theme-paint.e2e.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';import { stringify } from 'yaml';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {homeEnv,@@ -187,6 +188,7 @@ test.describe('saved theme paint smoke', () => {themeId: 'saved-personal-dark',backgroundColor: 'rgb(16, 32, 48)',});+ await configureDesktopGitRepositories(editor, projectDir);});test('palette assignments preserve the system slot and Default restores system appearance', async ({@@ -200,6 +202,7 @@ test.describe('saved theme paint smoke', () => {const app = await launchApp(tmpHome);captureStderrFor(app, { home: tmpHome, cleanupDirs: [tmpHome, projectDir] });const editor = await findEditorWindow(app);+ await configureDesktopGitRepositories(editor, projectDir);await editor.emulateMedia({ colorScheme: null });const systemDark = await app.evaluate(({ nativeTheme }) => nativeTheme.shouldUseDarkColors);const activeSlot = systemDark ? 'dark' : 'light';diff --git a/packages/desktop/tests/smoke/share-receive-miss-terminal.e2e.ts b/packages/desktop/tests/smoke/share-receive-miss-terminal.e2e.tsindex 74807dbfa..f2002dc3b 100644--- a/packages/desktop/tests/smoke/share-receive-miss-terminal.e2e.ts+++ b/packages/desktop/tests/smoke/share-receive-miss-terminal.e2e.ts@@ -4,6 +4,7 @@ import { mkdirSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } froimport { tmpdir } from 'node:os';import { basename, dirname, join } from 'node:path';import { _electron as electron } from '@playwright/test';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { PLATFORM_SKIP_REASON, PLATFORM_SUPPORTED } from './_helpers/platform-gate';import { expect, type SmokeFixtures, test } from './_helpers/smoke-test';@@ -100,9 +101,11 @@ function setupDeletedTargetFixture(options: MissFixtureOptions = {}): MissFixturmkdirSync(originDir);git(originDir, 'init', '--bare', '--initial-branch=main');+ configureTestGitRepository(originDir);mkdirSync(seedDir);git(seedDir, 'init', '--initial-branch=main');+ configureTestGitRepository(seedDir);git(seedDir, 'config', 'user.email', '[email protected]');git(seedDir, 'config', 'user.name', 'Test');git(seedDir, 'remote', 'add', 'origin', originDir);@@ -122,6 +125,7 @@ function setupDeletedTargetFixture(options: MissFixtureOptions = {}): MissFixturgit(seedDir, 'push', 'origin', 'main');git(root, 'clone', originDir, receiverDir);+ configureTestGitRepository(receiverDir);return { root, receiver: realpathSync(receiverDir), docPath };}diff --git a/packages/desktop/tests/smoke/share-receive-multi-worktree.e2e.ts b/packages/desktop/tests/smoke/share-receive-multi-worktree.e2e.tsindex 9caa3aded..4f429a654 100644--- a/packages/desktop/tests/smoke/share-receive-multi-worktree.e2e.ts+++ b/packages/desktop/tests/smoke/share-receive-multi-worktree.e2e.ts@@ -3,6 +3,7 @@ import { mkdirSync, mkdtempSync, realpathSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { _electron as electron } from '@playwright/test';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { expect, test } from './_helpers/smoke-test';@@ -35,6 +36,7 @@ function setupMultiWorktree(): MultiWorktreeFixture {const mainRepo = join(root, 'main');mkdirSync(mainRepo);gitSync(mainRepo, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(mainRepo);gitSync(mainRepo, 'config', 'user.email', '[email protected]');gitSync(mainRepo, 'config', 'user.name', 'Test');gitSync(mainRepo, 'remote', 'add', 'origin', 'https://github.com/inkeep/open-knowledge.git');@@ -50,6 +52,7 @@ function setupMultiWorktree(): MultiWorktreeFixture {const featBarWorktree = join(root, 'wt', 'feat-bar');mkdirSync(join(root, 'wt'), { recursive: true });gitSync(mainRepo, 'worktree', 'add', '-b', 'feat-bar', featBarWorktree);+ configureTestGitRepository(featBarWorktree);mkdirSync(join(featBarWorktree, 'docs'), { recursive: true });writeFileSync(join(featBarWorktree, 'docs', 'x.md'), '# feat-bar/docs/x\n');gitSync(featBarWorktree, 'add', 'docs/x.md');diff --git a/packages/desktop/tests/smoke/sidebar-create-rename-editable.e2e.ts b/packages/desktop/tests/smoke/sidebar-create-rename-editable.e2e.tsindex 17899bd68..08c988fd8 100644--- a/packages/desktop/tests/smoke/sidebar-create-rename-editable.e2e.ts+++ b/packages/desktop/tests/smoke/sidebar-create-rename-editable.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { SMOKE_ENABLED } from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';@@ -153,6 +154,7 @@ test.describe('Sidebar create and rename editability smoke', () => {captureStderrFor(app, { home: seed.tmpHome, cleanupDirs: [seed.tmpHome, seed.projectDir] });const page = await findEditorWindow(app, 'start');+ await configureDesktopGitRepositories(page, seed.projectDir);await expect(page.locator('.ProseMirror[contenteditable="true"]:not(.composer-prosemirror)').first(),).toBeVisible({diff --git a/packages/desktop/tests/smoke/sidebar-pill-lockstep-fade.e2e.ts b/packages/desktop/tests/smoke/sidebar-pill-lockstep-fade.e2e.tsindex ee45e36c0..abbb4a863 100644--- a/packages/desktop/tests/smoke/sidebar-pill-lockstep-fade.e2e.ts+++ b/packages/desktop/tests/smoke/sidebar-pill-lockstep-fade.e2e.ts@@ -4,6 +4,7 @@ import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { expect, test } from './_helpers/smoke-test';@@ -86,6 +87,7 @@ test.describe('sidebar search pill — Electron lockstep-fade smoke', () => {}).toPass({ timeout: 15_000 });if (!editorPage) throw new Error('unreachable');const page = editorPage;+ await configureDesktopGitRepositories(page, projectDir);const isElectronHost = await page.evaluate(() => typeof window !== 'undefined' && window.okDesktop != null,diff --git a/packages/desktop/tests/smoke/skill-scope-roundtrip.e2e.ts b/packages/desktop/tests/smoke/skill-scope-roundtrip.e2e.tsindex 8af35d54f..5cabc4e10 100644--- a/packages/desktop/tests/smoke/skill-scope-roundtrip.e2e.ts+++ b/packages/desktop/tests/smoke/skill-scope-roundtrip.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { expect, test } from './_helpers/smoke-test';const __dirname = dirname(fileURLToPath(import.meta.url));@@ -50,6 +51,7 @@ test.describe('Skill scope round-trip', () => {}throw new Error('project window never mounted from the argv deep-link');})();+ await configureDesktopGitRepositories(page, projectDir);const lockPath = join(projectDir, '.ok', 'local', 'server.lock');await expect(() => {diff --git a/packages/desktop/tests/smoke/skills-studio.e2e.ts b/packages/desktop/tests/smoke/skills-studio.e2e.tsindex e6f65296c..78b1f5deb 100644--- a/packages/desktop/tests/smoke/skills-studio.e2e.ts+++ b/packages/desktop/tests/smoke/skills-studio.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { expect, test } from './_helpers/smoke-test';const __dirname = dirname(fileURLToPath(import.meta.url));@@ -55,6 +56,7 @@ test.describe('Skills Studio', () => {}throw new Error('project window never mounted from the argv deep-link');})();+ await configureDesktopGitRepositories(page, projectDir);await page.getByTestId('header-settings-button').click();diff --git a/packages/desktop/tests/smoke/slidev-render-readiness.e2e.ts b/packages/desktop/tests/smoke/slidev-render-readiness.e2e.tsindex 2306cfdf1..b1190de75 100644--- a/packages/desktop/tests/smoke/slidev-render-readiness.e2e.ts+++ b/packages/desktop/tests/smoke/slidev-render-readiness.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { captureAppProcess, closeAppBounded } from './_helpers/electron-cleanup';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {@@ -135,6 +136,7 @@ test.describe('Slidev renderer readiness smoke', () => {.not.toBeUndefined();const editor = await findEditor(app);if (editor === undefined) throw new Error('editor window vanished after opening');+ await configureDesktopGitRepositories(editor, projectDir);const openResult = editor.evaluate(async (path) => {const slides = window.okDesktop?.slides;@@ -212,6 +214,7 @@ test.describe('Slidev renderer readiness smoke', () => {.not.toBeUndefined();const editor = await findEditor(app);if (editor === undefined) throw new Error('editor window vanished after opening');+ await configureDesktopGitRepositories(editor, projectDir);const openResult = editor.evaluate(async (path) => {const slides = window.okDesktop?.slides;diff --git a/packages/desktop/tests/smoke/spellcheck-presentation.e2e.ts b/packages/desktop/tests/smoke/spellcheck-presentation.e2e.tsindex 835682443..16ccec140 100644--- a/packages/desktop/tests/smoke/spellcheck-presentation.e2e.ts+++ b/packages/desktop/tests/smoke/spellcheck-presentation.e2e.ts@@ -1,4 +1,5 @@import type { Page } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { resolveDesktopTarget } from './_helpers/launch-desktop';import { PLATFORM_SKIP_REASON, PLATFORM_SUPPORTED, SMOKE_ENABLED } from './_helpers/platform-gate';import {@@ -139,6 +140,7 @@ test.describe('Spelling settings — platform presentation and editor non-interf},});const editor = await findEditorWindow(app);+ await configureDesktopGitRepositories(editor, profile.projectDir);await openProjectDocument(editor, SEEDED_DOC);diff --git a/packages/desktop/tests/smoke/spellcheck-settings.e2e.ts b/packages/desktop/tests/smoke/spellcheck-settings.e2e.tsindex 3db37984b..ca18a2854 100644--- a/packages/desktop/tests/smoke/spellcheck-settings.e2e.ts+++ b/packages/desktop/tests/smoke/spellcheck-settings.e2e.ts@@ -1,3 +1,4 @@+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { resolveDesktopTarget } from './_helpers/launch-desktop';import { PLATFORM_SKIP_REASON, PLATFORM_SUPPORTED, SMOKE_ENABLED } from './_helpers/platform-gate';import {@@ -61,6 +62,7 @@ test.describe('Spelling settings — real Electron surface', () => {},});const editor = await findEditorWindow(app);+ await configureDesktopGitRepositories(editor, profile.projectDir);const initial = await readSessionSpellingTruth(app);if (SELECTOR_RENDERS) {diff --git a/packages/desktop/tests/smoke/terminal-dock-state.e2e.ts b/packages/desktop/tests/smoke/terminal-dock-state.e2e.tsindex 5565f45a9..fe34ef487 100644--- a/packages/desktop/tests/smoke/terminal-dock-state.e2e.ts+++ b/packages/desktop/tests/smoke/terminal-dock-state.e2e.ts@@ -2,6 +2,7 @@ import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { waitForAgentsDockPublish } from './_helpers/dock-state-ready';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { waitForWindowByMode } from './_helpers/launch-readiness';@@ -55,6 +56,7 @@ test.describe('terminal dock-state IPC', () => {);captureStderrFor(app, { home: tmpHome, cleanupDirs: [testRoot] });const editorPage = await waitForWindowByMode(app, 'editor');+ await configureDesktopGitRepositories(editorPage, projectDir);await waitForAgentsDockPublish(() => editorPage.evaluate(() => window.okDesktop?.terminal.getDockState()),diff --git a/packages/desktop/tests/smoke/terminal-dock.e2e.ts b/packages/desktop/tests/smoke/terminal-dock.e2e.tsindex 11b8e66a5..f735f68d4 100644--- a/packages/desktop/tests/smoke/terminal-dock.e2e.ts+++ b/packages/desktop/tests/smoke/terminal-dock.e2e.ts@@ -11,6 +11,7 @@ import { tmpdir } from 'node:os';import { basename, join } from 'node:path';import type { ElectronApplication, Locator, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import {armDockRevealProbe,DOCK_REVEAL_BUDGET_MS,@@ -412,6 +413,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);await expect(page.getByRole('dialog')).toHaveCount(0);@@ -426,6 +428,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -443,6 +446,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await revealTerminalSurface(app, page.getByRole('region', { name: 'Terminal disabled' }));await expect(page.getByRole('button', { name: 'Enable terminal' })).toBeVisible();@@ -462,6 +466,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);expect(await viewTerminalLabel(app)).toBe('Show Terminal');await revealTerminalSurface(app, terminalSection(page));@@ -480,6 +485,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);expect(await terminalPlacementLabel(app)).toBe('Move Terminal to right');await clickTerminalPlacementItem(app, page);@@ -502,6 +508,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await widenEditorWindow(app, page, 1900, 900);await openTerminal(app, page);@@ -541,6 +548,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await widenEditorWindow(app, page, 1900, 900);await openTerminal(app, page);@@ -609,6 +617,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await widenEditorWindow(app, page, 1900, 900);await openTerminal(app, page);@@ -685,6 +694,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await waitForRendererResponsive(page);@@ -717,6 +727,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -740,6 +751,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -785,6 +797,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);await expect(page.getByRole('button', { name: 'Collapse Terminal' })).toBeVisible({@@ -803,6 +816,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -821,6 +835,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -839,6 +854,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -865,6 +881,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -895,6 +912,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);await ensureBottomDock(page);@@ -921,6 +939,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);await ensureBottomDock(page);@@ -980,6 +999,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -1008,6 +1028,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -1040,6 +1061,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true, connectionsAvailable: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -1119,6 +1141,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true, connectionsAvailable: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);for (let index = 0; index < 2; index += 1) {@@ -1199,6 +1222,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await openTerminal(app, page);await waitForStatus(page, 'running', 25_000);@@ -1231,6 +1255,7 @@ test.describe('Docked terminal — live Electron', () => {const app = await launchApp(s, { restrictPath: true });captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.realProjectDir);await page.evaluate(() => {localStorage.setItem('ok-ask-ai-agent-v2', 'terminal-cli:claude');diff --git a/packages/desktop/tests/smoke/terminal-launch-argv.e2e.ts b/packages/desktop/tests/smoke/terminal-launch-argv.e2e.tsindex f716c9f62..8200be879 100644--- a/packages/desktop/tests/smoke/terminal-launch-argv.e2e.ts+++ b/packages/desktop/tests/smoke/terminal-launch-argv.e2e.ts@@ -11,6 +11,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Locator, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { waitForWindowByMode } from './_helpers/launch-readiness';import { seedMcpConsentComplete } from './_helpers/mcp-consent';@@ -199,6 +200,7 @@ test.describe('Docked terminal launch — composed argv', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);const written = await page.evaluate(async () => {diff --git a/packages/desktop/tests/smoke/terminal-links.e2e.ts b/packages/desktop/tests/smoke/terminal-links.e2e.tsindex eb73077c0..74a97e228 100644--- a/packages/desktop/tests/smoke/terminal-links.e2e.ts+++ b/packages/desktop/tests/smoke/terminal-links.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { removeTempDirBestEffort } from '../support/temp-dir-cleanup.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { waitForWindowByMode } from './_helpers/launch-readiness';@@ -173,6 +174,7 @@ test.describe('Terminal clickable links — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await stubOpenExternal(app);await openRunningTerminal(app, page);@@ -193,6 +195,7 @@ test.describe('Terminal clickable links — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openRunningTerminal(app, page);await runInTerminal(page, SHELL_COMMANDS.output('notes.md'), 'notes.md');diff --git a/packages/desktop/tests/smoke/terminal-movement.e2e.ts b/packages/desktop/tests/smoke/terminal-movement.e2e.tsindex 1cf4812cf..89c373ee3 100644--- a/packages/desktop/tests/smoke/terminal-movement.e2e.ts+++ b/packages/desktop/tests/smoke/terminal-movement.e2e.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, ElementHandle, JSHandle, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { waitForWindowByMode } from './_helpers/launch-readiness';import { sumOfDeclaredBoundsMs } from './_helpers/parse-timeouts';@@ -501,6 +502,7 @@ test.describe('Terminal placement continuity — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await widenEditorWindow(app, page, 1900, 900);await openTerminal(app, page);@@ -590,6 +592,7 @@ test.describe('Terminal placement continuity — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await widenEditorWindow(app, page, 1900, 900);await openTerminal(app, page);@@ -714,6 +717,7 @@ test.describe('Terminal placement continuity — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);await expect(page.locator('#terminal-dock-panel')).toBeVisible();diff --git a/packages/desktop/tests/smoke/terminal-process-restart.e2e.ts b/packages/desktop/tests/smoke/terminal-process-restart.e2e.tsindex 01d8c3787..07e68ff51 100644--- a/packages/desktop/tests/smoke/terminal-process-restart.e2e.ts+++ b/packages/desktop/tests/smoke/terminal-process-restart.e2e.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import {type CrashDumpVerdict,type CrashDumpWatch,@@ -254,6 +255,7 @@ test.describe('terminal process restart', () => {const firstProcess = firstApp.process();const firstDumps = await watchCrashDumps(firstApp);const firstPage = await findEditorWindow(firstApp);+ await configureDesktopGitRepositories(firstPage, seed.projectDir);await setWindowSize(firstApp, firstPage, 1900, 900);await openTerminal(firstPage);const [firstTabId] = await terminalTabIds(firstPage);@@ -307,6 +309,7 @@ test.describe('terminal process restart', () => {const dumps = await watchCrashDumps(app);// WARN: mirrors the first process of the restart test aboveconst page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, seed.projectDir);await setWindowSize(app, page, 1900, 900);await openTerminal(page);const [firstTabId] = await terminalTabIds(page);diff --git a/packages/desktop/tests/smoke/terminal-tabs.e2e.ts b/packages/desktop/tests/smoke/terminal-tabs.e2e.tsindex 225362be6..f99e1c968 100644--- a/packages/desktop/tests/smoke/terminal-tabs.e2e.ts+++ b/packages/desktop/tests/smoke/terminal-tabs.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import type { ElectronApplication, Locator, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { launchDesktopApp, waitForWindowByMode } from './_helpers/launch-readiness';import { sumOfDeclaredBoundsMs } from './_helpers/parse-timeouts';@@ -199,6 +200,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);const expectPrompt = async () => {await expect(visibleSection(page)).toBeVisible();await expect@@ -220,6 +222,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await clickViewTerminalItem(app);await expect(visibleSection(page)).toBeVisible();await expect@@ -282,6 +285,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);const marker1 = `TAB1_PID_${Date.now().toString(36)}`;@@ -328,6 +332,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);await openBareTab(page);const [, survivingTabId] = await terminalTabIds(page);@@ -352,6 +357,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);await typeInActive(page, `${SHELL_COMMANDS.oscTitle('PROGRAM_TITLE_ZZZ', 'OSC_FED_QQQ')}\r`);@@ -394,6 +400,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);expect(@@ -434,6 +441,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);await typeInActive(page, `${SHELL_COMMANDS.setEnvironment('OK_TABMARK', 'SURVIVED_888')}\r`);@@ -482,6 +490,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);await typeInActive(@@ -525,6 +534,7 @@ test.describe('Terminal tabs — live Electron', () => {const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const page = await findEditorWindow(app);+ await configureDesktopGitRepositories(page, s.projectDir);await openTerminal(app, page);await openBareTab(page);diff --git a/packages/desktop/tests/smoke/terminal-window.e2e.ts b/packages/desktop/tests/smoke/terminal-window.e2e.tsindex a3fd28a50..1f6eeb2fa 100644--- a/packages/desktop/tests/smoke/terminal-window.e2e.ts+++ b/packages/desktop/tests/smoke/terminal-window.e2e.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { basename, join } from 'node:path';import type { ElectronApplication, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { waitForWindowByMode } from './_helpers/launch-readiness';import { sumOfDeclaredBoundsMs } from './_helpers/parse-timeouts';@@ -171,6 +172,7 @@ test.describe('Standalone terminal window — live Electron', () => {captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });const editor = await findEditorWindow(app);await waitForRendererResponsive(editor);+ await configureDesktopGitRepositories(editor, s.projectDir);const editorWindow = await app.browserWindow(editor);const editorWebContentsId = await editorWindow.evaluate((win: unknown) => (win as { webContents: { id: number } }).webContents.id,@@ -212,7 +214,9 @@ test.describe('Standalone terminal window — live Electron', () => {track(s.tmpHome, s.projectDir);const app = await launchApp(s);captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });- await waitForRendererResponsive(await findEditorWindow(app));+ const editor = await findEditorWindow(app);+ await waitForRendererResponsive(editor);+ await configureDesktopGitRepositories(editor, s.projectDir);expect(await clickNewTerminalWindow(app)).toBe(true);await findTerminalWindow(app);diff --git a/packages/desktop/tests/smoke/theme-sync.e2e.ts b/packages/desktop/tests/smoke/theme-sync.e2e.tsindex cb5effe36..ad0671775 100644--- a/packages/desktop/tests/smoke/theme-sync.e2e.ts+++ b/packages/desktop/tests/smoke/theme-sync.e2e.ts@@ -4,6 +4,7 @@ import { mkdirSync, mkdtempSync, realpathSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { _electron as electron } from '@playwright/test';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { homeEnv, userDataDirFor } from './_helpers/platform-gate';import { expect, test } from './_helpers/smoke-test';@@ -73,6 +74,7 @@ test.describe('chrome-modernization theme-sync smoke', () => {throw new Error(`no window matches ${expectedHashSuffix} yet`);}).toPass({ timeout: 15_000 });if (!editorPage) throw new Error('unreachable');+ await configureDesktopGitRepositories(editorPage, projectDir);const resolvedEditorPage = editorPage;const bridgeShape = await editorPage.evaluate(() => ({@@ -146,6 +148,7 @@ test.describe('chrome-modernization theme-sync smoke', () => {throw new Error(`no window matches ${expectedHashSuffix} yet`);}).toPass({ timeout: 15_000 });if (!editorPage) throw new Error('unreachable');+ await configureDesktopGitRepositories(editorPage, projectDir);await editorPage.evaluate(async () => {const bridge = window.okDesktop;@@ -266,6 +269,7 @@ test.describe('chrome-modernization theme-sync smoke', () => {throw new Error(`no window matches ${expectedHashSuffix} yet`);}).toPass({ timeout: 15_000 });if (!editorPage) throw new Error('unreachable');+ await configureDesktopGitRepositories(editorPage, projectDir);await app.evaluate(({ BrowserWindow }) => {const g = globalThis as unknown as Record<string, unknown>;diff --git a/packages/desktop/tests/smoke/unpackaged-open-file.e2e.ts b/packages/desktop/tests/smoke/unpackaged-open-file.e2e.tsindex 8279aad43..d6a171826 100644--- a/packages/desktop/tests/smoke/unpackaged-open-file.e2e.ts+++ b/packages/desktop/tests/smoke/unpackaged-open-file.e2e.ts@@ -2,6 +2,11 @@ import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { _electron as electron } from '@playwright/test';+import {+ configureDesktopGitRepositories,+ configureEphemeralGitRepositories,+ findEphemeralTestProject,+} from '../support/git-fixture.test-helper';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import { readBootLogLines } from './_helpers/launch-readiness';import {@@ -70,6 +75,10 @@ test.describe('unpackaged single-file open', () => {const editor = app.windows().find((window) => window !== navigator);if (editor === undefined) throw new Error('the single-file editor window vanished');await expect(editor.getByRole('heading', { name: 'Ephemeral file opened' })).toBeVisible();+ const apiOrigin = await editor.evaluate(() => window.okDesktop?.config.apiOrigin);+ if (!apiOrigin) throw new Error('the single-file editor has no server origin');+ const projectDir = findEphemeralTestProject(tmpHome, apiOrigin);+ await configureEphemeralGitRepositories(projectDir, apiOrigin);await app.evaluate(({ app: electronApp }) => {setImmediate(() => electronApp.quit());});@@ -115,6 +124,10 @@ test.describe('unpackaged single-file open', () => {).toBe(true);+ const editor = app.windows().find((window) => window !== navigator);+ if (editor === undefined) throw new Error('the project editor window vanished');+ await configureDesktopGitRepositories(editor, projectDir);+await app.evaluate(({ app: electronApp }) => {setImmediate(() => electronApp.quit());});diff --git a/packages/desktop/tests/smoke/window-chrome.e2e.ts b/packages/desktop/tests/smoke/window-chrome.e2e.tsindex 352a58ceb..969aa933e 100644--- a/packages/desktop/tests/smoke/window-chrome.e2e.ts+++ b/packages/desktop/tests/smoke/window-chrome.e2e.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import type { ElectronApplication, JSHandle, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';import { CHROME_BG } from '../../src/main/window-chrome.ts';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {homeEnv,@@ -127,6 +128,7 @@ test.describe('Windows/Linux window chrome smoke', () => {if (process.platform === 'win32') {expect(overlay.visible).toBe(true);}+ await configureDesktopGitRepositories(editor, projectDir);});});@@ -143,6 +145,7 @@ test.describe('Editor header drag-region smoke', () => {captureStderrFor(app, { home: tmpHome, cleanupDirs: [tmpHome, projectDir] });const editor = await findEditorWindow(app);+ await configureDesktopGitRepositories(editor, projectDir);const filesToggle = editor.locator('[data-editor-header-leading-actions]').locator('[data-sidebar="trigger"]');diff --git a/packages/desktop/tests/smoke/window-min-size.e2e.ts b/packages/desktop/tests/smoke/window-min-size.e2e.tsindex 5fc5c10d5..485228133 100644--- a/packages/desktop/tests/smoke/window-min-size.e2e.ts+++ b/packages/desktop/tests/smoke/window-min-size.e2e.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import type { ElectronApplication, JSHandle, Page } from '@playwright/test';import { _electron as electron } from '@playwright/test';import { WINDOW_MIN_SIZE } from '../../src/main/window-min-size.ts';+import { configureDesktopGitRepositories } from '../support/git-fixture.test-helper.ts';import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';import {homeEnv,@@ -131,6 +132,7 @@ test.describe('BrowserWindow min-size smoke', () => {WINDOW_MIN_SIZE.EDITOR.width,WINDOW_MIN_SIZE.EDITOR.height,]);+ await configureDesktopGitRepositories(editor, projectDir);await editor.evaluate(async () => {await window.okDesktop?.navigator.open();diff --git a/packages/desktop/tests/support/git-fixture.test-helper.ts b/packages/desktop/tests/support/git-fixture.test-helper.tsnew file mode 100644index 000000000..998024dbe--- /dev/null+++ b/packages/desktop/tests/support/git-fixture.test-helper.ts@@ -0,0 +1,116 @@+import assert from 'node:assert/strict';+import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync } from 'node:fs';+import { basename, dirname, isAbsolute, join } from 'node:path';+import { inspectGitRepository } from '@inkeep/open-knowledge-core/git-repository';+import { EPHEMERAL_PROJECT_DIR_PREFIX } from '@inkeep/open-knowledge-server';+import type { Page } from '@playwright/test';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';++async function waitForServerReady(projectDir: string, apiOrigin: string): Promise<void> {+ const response = await fetch(new URL('/api/server-info', apiOrigin));+ await response.arrayBuffer();+ if (!response.ok) {+ throw new Error(`Server readiness failed for ${projectDir}: HTTP ${response.status}`);+ }+}++function configureRepositories(projectDir: string): void {+ const main = inspectGitRepository(projectDir);+ if (main.kind === 'repository') {+ if (+ main.repository.kind === 'linked' ||+ existsSync(join(main.repository.gitDir, 'HEAD')) ||+ existsSync(join(main.repository.gitDir, 'config'))+ ) {+ configureTestGitRepository(projectDir);+ }+ } else if (main.kind !== 'absent') {+ throw new Error(`Cannot inspect fixture repository at ${projectDir}: ${main.kind}`);+ }+}++export async function configureProjectGitRepositories(+ projectDir: string,+ apiOrigin: string,+): Promise<void> {+ await waitForServerReady(projectDir, apiOrigin);+ configureRepositories(projectDir);+}++export async function configureDesktopGitRepositories(+ page: Page,+ projectDir: string,+): Promise<void> {+ const apiOrigin = await page.evaluate(() => window.okDesktop?.config.apiOrigin);+ if (!apiOrigin) throw new Error(`Desktop fixture has no server origin for ${projectDir}`);+ await configureProjectGitRepositories(projectDir, apiOrigin);+}++export function readTestServerRepository(lockDir: string): {+ projectDir: string;+ apiOrigin: string;+ port: number;+} {+ const lockPath = join(lockDir, 'server.lock');+ for (const path of [dirname(dirname(lockDir)), dirname(lockDir), lockDir, lockPath]) {+ if (lstatSync(path).isSymbolicLink()) {+ throw new Error(`Fixture server path is a symlink: ${path}`);+ }+ }+ const lock: unknown = JSON.parse(readFileSync(lockPath, 'utf8'));+ assert(lock !== null && typeof lock === 'object', `Invalid fixture metadata at ${lockPath}`);+ assert(+ 'worktreeRoot' in lock &&+ typeof lock.worktreeRoot === 'string' &&+ isAbsolute(lock.worktreeRoot),+ `Invalid fixture root at ${lockPath}`,+ );+ assert('url' in lock && typeof lock.url === 'string', `Missing fixture URL at ${lockPath}`);+ assert(+ 'port' in lock && typeof lock.port === 'number' && lock.port > 0,+ `Invalid fixture port at ${lockPath}`,+ );+ const projectDir = realpathSync(lock.worktreeRoot);+ if (realpathSync(lockDir) !== join(projectDir, '.ok', 'local')) {+ throw new Error(`Fixture server root does not own ${lockPath}`);+ }+ const url = new URL(lock.url);+ if (Number(url.port) !== lock.port) {+ throw new Error(`Fixture server URL does not match port at ${lockPath}`);+ }+ return { projectDir, apiOrigin: url.origin, port: lock.port };+}++export function findEphemeralTestProject(ownedTempDir: string, apiOrigin: string): string {+ const tempDir = realpathSync(ownedTempDir);+ const origin = new URL(apiOrigin).origin;+ const matches: string[] = [];+ for (const entry of readdirSync(tempDir, { withFileTypes: true })) {+ if (!entry.isDirectory() || !entry.name.startsWith(EPHEMERAL_PROJECT_DIR_PREFIX)) continue;+ const projectDir = join(tempDir, entry.name);+ const lockDir = join(projectDir, '.ok', 'local');+ if (!existsSync(join(lockDir, 'server.lock'))) continue;+ const server = readTestServerRepository(lockDir);+ if (server.projectDir !== projectDir) {+ throw new Error(`Ephemeral fixture root does not match ${projectDir}`);+ }+ if (server.apiOrigin === origin) matches.push(projectDir);+ }+ const projectDir = matches[0];+ if (matches.length !== 1 || projectDir === undefined) {+ throw new Error(`Expected one ephemeral fixture for ${origin}; found ${matches.length}`);+ }+ return projectDir;+}++export async function configureEphemeralGitRepositories(+ projectDir: string,+ apiOrigin: string,+): Promise<void> {+ await waitForServerReady(projectDir, apiOrigin);+ const root = realpathSync(projectDir);+ if (!basename(root).startsWith(EPHEMERAL_PROJECT_DIR_PREFIX)) {+ throw new Error(`Unexpected ephemeral fixture root ${root}`);+ }+ configureRepositories(root);+}diff --git a/packages/desktop/tests/support/git-fixture.test.ts b/packages/desktop/tests/support/git-fixture.test.tsnew file mode 100644index 000000000..bac569140--- /dev/null+++ b/packages/desktop/tests/support/git-fixture.test.ts@@ -0,0 +1,197 @@+import { execFileSync } from 'node:child_process';+import { once } from 'node:events';+import {+ existsSync,+ mkdirSync,+ mkdtempSync,+ readFileSync,+ realpathSync,+ rmSync,+ symlinkSync,+ writeFileSync,+} from 'node:fs';+import { createServer, type Server } from 'node:http';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { resolveShadowDir } from '@inkeep/open-knowledge-core/shadow-repo-layout';+import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';+import {+ configureEphemeralGitRepositories,+ configureProjectGitRepositories,+ findEphemeralTestProject,+ readTestServerRepository,+} from './git-fixture.test-helper.ts';++function git(directory: string, args: string[]): string {+ return execFileSync('git', ['-C', directory, ...args], {+ encoding: 'utf8',+ env: Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_'))),+ stdio: 'pipe',+ }).trim();+}++function createShadow(projectDir: string): string {+ const shadowDir = join(projectDir, '.git', 'ok');+ git(projectDir, ['init', '--bare', shadowDir]);+ configureTestGitRepository(shadowDir);+ git(shadowDir, ['config', '--unset', 'core.bare']);+ git(shadowDir, ['config', 'core.worktree', projectDir]);+ return shadowDir;+}++function maintenance(repository: string): string {+ return git(repository, ['config', '--local', '--get', 'maintenance.auto']);+}++describe('desktop Git fixture ownership', () => {+ let root: string;+ let server: Server | undefined;++ beforeEach(() => {+ root = realpathSync(mkdtempSync(join(tmpdir(), 'ok-desktop-git-fixture-')));+ });++ afterEach(async () => {+ if (server) {+ const closed = once(server, 'close');+ server.close();+ await closed;+ server = undefined;+ }+ rmSync(root, { recursive: true, force: true });+ });++ async function serveReady(status = 200, gate = Promise.resolve()): Promise<string> {+ server = createServer((_request, response) => {+ void gate.then(() => {+ response.writeHead(status, { 'Content-Type': 'application/json' });+ response.end('{}');+ });+ });+ server.listen(0, '127.0.0.1');+ await once(server, 'listening');+ const address = server.address();+ if (!address || typeof address === 'string') throw new Error('Fixture server has no port');+ return `http://127.0.0.1:${address.port}`;+ }++ test('joins readiness before configuring the main repository and leaves its shadow untouched', async () => {+ git(root, ['init']);+ configureTestGitRepository(root);+ const shadow = createShadow(root);+ git(root, ['config', '--local', 'maintenance.auto', 'true']);+ git(shadow, ['config', '--local', 'maintenance.auto', 'true']);+ const gate = Promise.withResolvers<void>();+ const origin = await serveReady(200, gate.promise);+ if (!server) throw new Error('Fixture server was not started');+ const request = once(server, 'request');+ const configured = configureProjectGitRepositories(root, origin);+ try {+ await request;+ expect(maintenance(root)).toBe('true');+ expect(maintenance(shadow)).toBe('true');+ } finally {+ gate.resolve();+ await configured;+ }+ expect(maintenance(root)).toBe('false');+ expect(maintenance(shadow)).toBe('true');+ });++ test('leaves a shadow-only project untouched without creating a main Git config', async () => {+ const shadow = createShadow(root);+ git(shadow, ['config', '--local', 'maintenance.auto', 'true']);+ await configureProjectGitRepositories(root, await serveReady());+ expect(maintenance(shadow)).toBe('true');+ expect(existsSync(join(root, '.git', 'config'))).toBe(false);+ expect(existsSync(join(root, '.git', 'HEAD'))).toBe(false);+ });++ test('configures linked worktree common config and leaves the worktree shadow untouched', async () => {+ git(root, ['init']);+ configureTestGitRepository(root);+ git(root, [+ '-c',+ 'user.name=fixture',+ '-c',+ '[email protected]',+ 'commit',+ '--allow-empty',+ '-m',+ 'fixture',+ ]);+ const linked = join(root, 'linked');+ git(root, ['worktree', 'add', '--detach', linked]);+ const shadow = resolveShadowDir(linked);+ git(linked, ['init', '--bare', shadow]);+ configureTestGitRepository(shadow);+ git(root, ['config', '--local', 'maintenance.auto', 'true']);+ git(shadow, ['config', '--local', 'maintenance.auto', 'true']);+ await configureProjectGitRepositories(linked, await serveReady());+ expect(maintenance(root)).toBe('false');+ expect(maintenance(linked)).toBe('false');+ expect(maintenance(shadow)).toBe('true');+ });++ test('propagates HTTP failure without configuring the repository', async () => {+ git(root, ['init']);+ configureTestGitRepository(root);+ git(root, ['config', '--local', 'maintenance.auto', 'true']);+ await expect(configureProjectGitRepositories(root, await serveReady(503))).rejects.toThrow(+ 'HTTP 503',+ );+ expect(maintenance(root)).toBe('true');+ });++ test('propagates an actual Git config lock failure', async () => {+ git(root, ['init']);+ configureTestGitRepository(root);+ git(root, ['config', '--local', 'maintenance.auto', 'true']);+ const lock = join(root, '.git', 'config.lock');+ writeFileSync(lock, 'owned contention');+ await expect(configureProjectGitRepositories(root, await serveReady())).rejects.toThrow(+ 'could not lock config file',+ );+ expect(maintenance(root)).toBe('true');+ expect(readFileSync(lock, 'utf8')).toBe('owned contention');+ });++ test('selects only the matching direct owned root and rejects ambiguous or mismatched metadata', async () => {+ const origin = await serveReady();+ const port = Number(new URL(origin).port);+ const project = join(root, 'ok-ephemeral-selected');+ const lockDir = join(project, '.ok', 'local');+ mkdirSync(lockDir, { recursive: true });+ git(project, ['init']);+ configureTestGitRepository(project);+ git(project, ['config', '--local', 'maintenance.auto', 'true']);+ const shadow = createShadow(project);+ git(shadow, ['config', '--local', 'maintenance.auto', 'true']);+ const metadata = { worktreeRoot: project, url: origin, port };+ writeFileSync(join(lockDir, 'server.lock'), JSON.stringify(metadata));+ const nested = join(root, 'nested', 'ok-ephemeral-nested');+ mkdirSync(nested, { recursive: true });+ symlinkSync(project, join(root, 'ok-ephemeral-symlink'), 'junction');+ expect(findEphemeralTestProject(root, origin)).toBe(project);+ expect(() => findEphemeralTestProject(root, 'http://127.0.0.1:1')).toThrow('found 0');+ await configureEphemeralGitRepositories(project, origin);+ expect(maintenance(project)).toBe('false');+ expect(maintenance(shadow)).toBe('true');+ const duplicate = join(root, 'ok-ephemeral-duplicate');+ const duplicateLock = join(duplicate, '.ok', 'local');+ mkdirSync(duplicateLock, { recursive: true });+ writeFileSync(+ join(duplicateLock, 'server.lock'),+ JSON.stringify({ ...metadata, worktreeRoot: duplicate }),+ );+ expect(() => findEphemeralTestProject(root, origin)).toThrow('found 2');+ writeFileSync(join(duplicateLock, 'server.lock'), JSON.stringify(metadata));+ expect(() => readTestServerRepository(duplicateLock)).toThrow('does not own');+ writeFileSync(+ join(duplicateLock, 'server.lock'),+ JSON.stringify({ ...metadata, worktreeRoot: duplicate, url: 'not-a-url' }),+ );+ expect(() => readTestServerRepository(duplicateLock)).toThrow();+ });+});diff --git a/packages/desktop/tests/utility/server-entry.test.ts b/packages/desktop/tests/utility/server-entry.test.tsindex 9b4a9c74b..6c5122a51 100644--- a/packages/desktop/tests/utility/server-entry.test.ts+++ b/packages/desktop/tests/utility/server-entry.test.ts@@ -6,6 +6,7 @@ import { setTimeout as wait } from 'node:timers/promises';import { resolveServerRuntimeConfig } from '@inkeep/open-knowledge-core';import { ConfigSchema } from '@inkeep/open-knowledge-server';import { beforeEach, describe, expect, type Mock, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { UTILITY_INIT_PHASES } from '../../src/shared/boot-narration.ts';import type { KeyringSmokeResult } from '../../src/utility/keyring-smoke.ts';import {@@ -929,6 +930,7 @@ describe('handleInit defaultPrepareBootEnvironment (integration)', () => {},});await handle.readyPromise;+ configureTestGitRepository(tmpRoot);const headPath = resolve(tmpRoot, '.git/HEAD');const configPath = resolve(tmpRoot, '.ok/config.yml');@@ -1201,6 +1203,7 @@ describe('setupUtility narrates its startup phases to main before it reports rea},});await handle.readyPromise;+ if (!didEnsureGit) configureTestGitRepository(tmpRoot);const posted = postedToMain(env);const marks = posted.filter((message) => message.type === 'init-phase');diff --git a/packages/server/share-v2-smoke.ts b/packages/server/share-v2-smoke.tsindex 73b6209de..8d9b90f99 100644--- a/packages/server/share-v2-smoke.ts+++ b/packages/server/share-v2-smoke.ts@@ -17,7 +17,7 @@ const GITHUB_REPOSITORY = 'https://github.com/inkeep/open-knowledge';process.env.LOG_LEVEL ??= 'silent';const [{ bootEndpointServer }, { createGitTriangle }] = await Promise.all([import('./src/share/endpoint-http.test-helper.ts'),- import('./src/share/git-fixture.test-helper.ts'),+ import('./tests/support/git-fixture.test-helper.ts'),]);async function constructShare(port: number, body: unknown): Promise<ShareSuccess> {diff --git a/packages/server/src/api-agent-write-extension.test.ts b/packages/server/src/api-agent-write-extension.test.tsindex 18d118401..48706ae48 100644--- a/packages/server/src/api-agent-write-extension.test.ts+++ b/packages/server/src/api-agent-write-extension.test.ts@@ -5,6 +5,7 @@ import { join } from 'node:path';import { Readable } from 'node:stream';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { _resetDocExtensionsForTests, getDocExtension } from './doc-extensions.ts';import { createServer } from './server-factory.ts';@@ -97,6 +98,7 @@ describe('agent-write-md explicit extension → disk (PRD-6836)', () => {contentDir = tmpDir;const git = simpleGit({ baseDir: tmpDir });await git.init();+ configureTestGitRepository(tmpDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');});diff --git a/packages/server/src/api-config-system-composition.test.ts b/packages/server/src/api-config-system-composition.test.tsindex 8d9c21d41..98e5357d0 100644--- a/packages/server/src/api-config-system-composition.test.ts+++ b/packages/server/src/api-config-system-composition.test.ts@@ -14,6 +14,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import { resolveShadowDir } from '@inkeep/open-knowledge-core/shadow-repo-layout';import { afterAll, afterEach, beforeAll, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import type { BootedServer } from './boot.ts';import { CC1Broadcaster } from './cc1-broadcast.ts';import {@@ -543,6 +544,7 @@ describe('server-info branch reporting over the composed listener', () => {try {const server = await bootOn('repo-', (dir) => {execFileSync('git', ['init', '-q', '-b', 'feat/probe'], { cwd: dir });+ configureTestGitRepository(dir);});expect(await currentBranchOf(server)).toBe('feat/probe');@@ -559,6 +561,7 @@ describe('server-info branch reporting over the composed listener', () => {try {const server = await bootOn('watcher-failed-', (dir) => {execFileSync('git', ['init', '-q', '-b', 'feat/probe'], { cwd: dir });+ configureTestGitRepository(dir);});expect(server.degraded).toContain('head-watcher');diff --git a/packages/server/src/api-extension.branch-info.test.ts b/packages/server/src/api-extension.branch-info.test.tsindex 3c541ed6c..03d44bb31 100644--- a/packages/server/src/api-extension.branch-info.test.ts+++ b/packages/server/src/api-extension.branch-info.test.ts@@ -4,6 +4,7 @@ import type { Server } from 'node:http';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { listenOnLoopback } from './loopback-rig-test-helpers.ts';interface TestRig {@@ -30,6 +31,7 @@ function commitAll(cwd: string, message: string): void {function initRepo(cwd: string): void {run(cwd, 'git init -q -b main');+ configureTestGitRepository(cwd);run(cwd, 'git config user.email "[email protected]"');run(cwd, 'git config user.name "Test"');run(cwd, 'git config commit.gpgsign false');diff --git a/packages/server/src/api-extension.checkout.test.ts b/packages/server/src/api-extension.checkout.test.tsindex 42acf8c37..1bd83edb2 100644--- a/packages/server/src/api-extension.checkout.test.ts+++ b/packages/server/src/api-extension.checkout.test.ts@@ -4,6 +4,7 @@ import type { Server } from 'node:http';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { listenOnLoopback } from './loopback-rig-test-helpers.ts';interface TestRig {@@ -30,6 +31,7 @@ function commitAll(cwd: string, message: string): void {function initRepo(cwd: string): void {run(cwd, 'git init -q -b main');+ configureTestGitRepository(cwd);run(cwd, 'git config user.email "[email protected]"');run(cwd, 'git config user.name "Test"');run(cwd, 'git config commit.gpgsign false');@@ -162,6 +164,7 @@ describe('POST /api/git/checkout', () => {run(upstreamDir, 'git checkout -q main');rmSync(projectDir, { recursive: true, force: true });run(tmpRoot, `git clone -q ${upstreamDir} ${projectDir}`);+ configureTestGitRepository(projectDir);run(projectDir, 'git config user.email "[email protected]"');run(projectDir, 'git config user.name "Test"');run(projectDir, 'git config commit.gpgsign false');@@ -205,6 +208,7 @@ describe('POST /api/git/checkout', () => {commitAll(upstreamDir, 'init');rmSync(projectDir, { recursive: true, force: true });run(tmpRoot, `git clone -q ${upstreamDir} ${projectDir}`);+ configureTestGitRepository(projectDir);run(projectDir, 'git config user.email "[email protected]"');run(projectDir, 'git config user.name "Test"');run(projectDir, 'git config commit.gpgsign false');@@ -225,6 +229,7 @@ describe('POST /api/git/checkout', () => {commitAll(upstreamDir, 'init');rmSync(projectDir, { recursive: true, force: true });run(tmpRoot, `git clone -q ${upstreamDir} ${projectDir}`);+ configureTestGitRepository(projectDir);run(projectDir, 'git config user.email "[email protected]"');run(projectDir, 'git config user.name "Test"');run(projectDir, 'git config commit.gpgsign false');diff --git a/packages/server/src/api-extension.ok-init.test.ts b/packages/server/src/api-extension.ok-init.test.tsindex 6bdb3e27a..f3b113b3a 100644--- a/packages/server/src/api-extension.ok-init.test.ts+++ b/packages/server/src/api-extension.ok-init.test.ts@@ -12,6 +12,7 @@ import type { Server } from 'node:http';import { homedir, tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { listenOnLoopback } from './loopback-rig-test-helpers.ts';interface TestConcurrencyGuard {@@ -33,6 +34,7 @@ function run(cwd: string, cmd: string): string {function initRepo(cwd: string): void {run(cwd, 'git init -q -b main');+ configureTestGitRepository(cwd);run(cwd, 'git config user.email "[email protected]"');run(cwd, 'git config user.name "Test"');run(cwd, 'git config commit.gpgsign false');diff --git a/packages/server/src/api-file-ops.test.ts b/packages/server/src/api-file-ops.test.tsindex 98598fc70..57bfd7256 100644--- a/packages/server/src/api-file-ops.test.ts+++ b/packages/server/src/api-file-ops.test.ts@@ -17,6 +17,7 @@ import { Hocuspocus } from '@hocuspocus/server';import simpleGit from 'simple-git';import { afterEach, describe, expect, test, vi } from 'vitest';import type * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {createApiExtension,createDerivedDocumentIndexApiPortStub,@@ -1080,6 +1081,7 @@ describe('file operation API routes', () => {const git = simpleGit(dir);await git.init();+ configureTestGitRepository(dir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');await git.add('.');@@ -1117,6 +1119,7 @@ describe('file operation API routes', () => {const git = simpleGit(dir);await git.init();+ configureTestGitRepository(dir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');await git.add('.');@@ -1161,6 +1164,7 @@ describe('file operation API routes', () => {const git = simpleGit(dir);await git.init();+ configureTestGitRepository(dir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');await git.add('.');@@ -1185,6 +1189,7 @@ describe('file operation API routes', () => {const git = simpleGit(dir);await git.init();+ configureTestGitRepository(dir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');await git.add('.');diff --git a/packages/server/src/api-rename-crash-injection.test.ts b/packages/server/src/api-rename-crash-injection.test.tsindex 2b83176e5..ba0f3df30 100644--- a/packages/server/src/api-rename-crash-injection.test.ts+++ b/packages/server/src/api-rename-crash-injection.test.ts@@ -14,6 +14,7 @@ import { join, resolve } from 'node:path';import { Readable } from 'node:stream';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createApiExtension } from './api-extension.test-helper.ts';import { BacklinkIndex } from './backlink-index.ts';import { swapContributors } from './contributor-tracker.ts';@@ -83,6 +84,7 @@ beforeEach(async () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addConfig('user.name', 'Test');await git.addConfig('user.email', '[email protected]');writeFileSync(resolve(contentDir, 'a.md'), '# A original\n');diff --git a/packages/server/src/api-rename-log-emission.test.ts b/packages/server/src/api-rename-log-emission.test.tsindex a26d3630e..69bdccaed 100644--- a/packages/server/src/api-rename-log-emission.test.ts+++ b/packages/server/src/api-rename-log-emission.test.ts@@ -14,6 +14,7 @@ import { join, resolve } from 'node:path';import { Readable } from 'node:stream';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createApiExtension } from './api-extension.test-helper.ts';import { BacklinkIndex } from './backlink-index.ts';import { recordContributor, swapContributors } from './contributor-tracker.ts';@@ -83,6 +84,7 @@ beforeEach(async () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addConfig('user.name', 'Test');await git.addConfig('user.email', '[email protected]');writeFileSync(resolve(contentDir, 'placeholder.md'), '# placeholder\n');diff --git a/packages/server/src/api-rollback-actor-identity.test.ts b/packages/server/src/api-rollback-actor-identity.test.tsindex c7767a2fb..961b7943b 100644--- a/packages/server/src/api-rollback-actor-identity.test.ts+++ b/packages/server/src/api-rollback-actor-identity.test.ts@@ -7,6 +7,7 @@ import type { Principal } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createApiExtension } from './api-extension.test-helper.ts';import { BacklinkIndex } from './backlink-index.ts';import {@@ -80,6 +81,7 @@ async function setupRollback(tmpDir: string): Promise<RollbackHarness> {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');await git.add('.');diff --git a/packages/server/src/api-rollback-rename-history.test.ts b/packages/server/src/api-rollback-rename-history.test.tsindex c4666043a..21e722502 100644--- a/packages/server/src/api-rollback-rename-history.test.ts+++ b/packages/server/src/api-rollback-rename-history.test.ts@@ -6,6 +6,7 @@ import { Readable } from 'node:stream';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createApiExtension } from './api-extension.test-helper.ts';import { BacklinkIndex } from './backlink-index.ts';import { swapContributors } from './contributor-tracker.ts';@@ -98,6 +99,7 @@ describe('handleRollback — rename history mitigation (US-005)', () => {writeFileSync(resolve(contentDir, 'placeholder.md'), '# placeholder\n');const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');await git.add('.');diff --git a/packages/server/src/api-skill-recovery-composition.test.ts b/packages/server/src/api-skill-recovery-composition.test.tsindex acb1d6f04..0b0f96f70 100644--- a/packages/server/src/api-skill-recovery-composition.test.ts+++ b/packages/server/src/api-skill-recovery-composition.test.ts@@ -17,6 +17,7 @@ import {SkillsReimportBulkSuccessSchema,} from '@inkeep/open-knowledge-core';import { afterAll, beforeAll, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import type { BootedServer } from './boot.ts';import { bootCompositionRig, rawRequest } from './composition-rig.test-helper.ts';import { ensureProjectGit } from './project-git.ts';@@ -32,6 +33,7 @@ beforeAll(async () => {source = mkdtempSync(join(tmpdir(), 'ok-recovery-source-'));mkdirSync(join(root, '.claude'));await ensureProjectGit(root);+ configureTestGitRepository(root);server = await bootCompositionRig(root, { gitEnabled: true });await server.ready;}, 60_000);diff --git a/packages/server/src/api-skill-tracking-composition.test.ts b/packages/server/src/api-skill-tracking-composition.test.tsindex 7637cbed4..be6d34173 100644--- a/packages/server/src/api-skill-tracking-composition.test.ts+++ b/packages/server/src/api-skill-tracking-composition.test.ts@@ -13,6 +13,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { Readable } from 'node:stream';import { afterAll, afterEach, beforeAll, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createApiExtension } from './api-extension.test-helper.ts';import type { BootedServer } from './boot.ts';import {@@ -50,6 +51,7 @@ function gitIgnored(base: string, path: string): boolean {beforeAll(async () => {root = realpathSync(mkdtempSync(join(tmpdir(), 'ok-skill-tracking-')));const result = spawnSync('git', ['init', '-q', root]);+ configureTestGitRepository(root);expect(result.status).toBe(0);writeSkill(root, '.agents/skills/open-knowledge', 'open-knowledge');writeSkill(root, '.claude/skills/hidden', 'hidden');diff --git a/packages/server/src/bash/path-honesty-contract.test.ts b/packages/server/src/bash/path-honesty-contract.test.tsindex 31dd65ed8..9a739cd4e 100644--- a/packages/server/src/bash/path-honesty-contract.test.ts+++ b/packages/server/src/bash/path-honesty-contract.test.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import simpleGit from 'simple-git';import { afterAll, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { ConfigSchema } from '../config/schema.ts';import { buildExecResult } from '../mcp/tools/exec.ts';@@ -18,6 +19,7 @@ async function corpus(): Promise<string> {created.push(root);const git = simpleGit(root);await git.init();+ configureTestGitRepository(root);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');mkdirSync(join(root, 'specs'));diff --git a/packages/server/src/boot-shadow-housekeeping-deferral.test.ts b/packages/server/src/boot-shadow-housekeeping-deferral.test.tsindex 31a1186df..84f6da8f5 100644--- a/packages/server/src/boot-shadow-housekeeping-deferral.test.ts+++ b/packages/server/src/boot-shadow-housekeeping-deferral.test.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';function makeGate() {let release!: () => void;@@ -88,6 +89,7 @@ describe('createServer() — boot shadow housekeeping is deferred past ready', (projectDir = await mkdtemp(join(tmpdir(), 'ok-boot-housekeeping-'));const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');await git.raw('commit', '--allow-empty', '-m', 'seed');diff --git a/packages/server/src/boot-skill-ownership.test.ts b/packages/server/src/boot-skill-ownership.test.tsindex 65fd65d6a..f2efcb858 100644--- a/packages/server/src/boot-skill-ownership.test.ts+++ b/packages/server/src/boot-skill-ownership.test.ts@@ -14,6 +14,7 @@ import {import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, beforeEach, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import type { BootedServer } from './boot.ts';import { bootCompositionRig } from './composition-rig.test-helper.ts';@@ -55,6 +56,7 @@ function git(...args: string[]): string {test('startup preserves tracked dangling skill links without a legacy store', async () => {git('init', '--quiet', '--initial-branch=main');+ configureTestGitRepository(root);writeFileSync(join(root, '.gitignore'), '.ok/\n');const target = '../../shared-skills/retired';const links = ['.agents/skills/retired', '.codex/skills/retired'];diff --git a/packages/server/src/boot.test.ts b/packages/server/src/boot.test.tsindex c0517967d..047a425c1 100644--- a/packages/server/src/boot.test.ts+++ b/packages/server/src/boot.test.ts@@ -14,6 +14,7 @@ import {SimpleSpanProcessor,} from '@opentelemetry/sdk-trace-base';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { bootServer } from './boot.ts';import { getBootTimings } from './boot-timings.ts';import { ConfigSchema } from './config/schema.ts';@@ -45,6 +46,7 @@ describe('bootServer — MissingOkConfigError pre-listen check', () => {test('rejects with kind=okdir when .ok/ directory is absent (State A)', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'state-a-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);let caught: unknown;try {@@ -73,6 +75,7 @@ describe('bootServer — MissingOkConfigError pre-listen check', () => {test('rejects with kind=config when .ok/ exists but config.yml is missing (State B)', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'state-b-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);const okDir = resolve(contentDir, '.ok');writeFileSync(resolve(contentDir, 'placeholder'), '');await execFileAsync('mkdir', [okDir]);@@ -102,6 +105,7 @@ describe('bootServer — MissingOkConfigError pre-listen check', () => {test('preflight checks projectDir/.ok/config.yml when projectDir != contentDir', async () => {const projectDir = mkdtempSync(resolve(tmpDir, 'projectdir-preflight-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);seedOkScaffold(projectDir);const contentDir = resolve(projectDir, 'docs');mkdirSync(contentDir, { recursive: true });@@ -128,6 +132,7 @@ describe('bootServer — MissingOkConfigError pre-listen check', () => {test('rejects when projectDir/.ok/config.yml is missing even though contentDir/.ok/config.yml exists', async () => {const projectDir = mkdtempSync(resolve(tmpDir, 'projectdir-only-content-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);const contentDir = resolve(projectDir, 'docs');mkdirSync(contentDir, { recursive: true });seedOkScaffold(contentDir);@@ -157,6 +162,7 @@ describe('bootServer — MissingOkConfigError pre-listen check', () => {test('proceeds and emits a one-time stderr warning when only .ok/.gitignore is missing (State C)', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'state-c-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);const okDir = resolve(contentDir, '.ok');await execFileAsync('mkdir', [okDir]);writeFileSync(resolve(okDir, 'config.yml'), '', 'utf-8');@@ -190,6 +196,7 @@ describe('bootServer — runtime state lives at projectDir, not contentDir', ()test('boot writes server.lock, principal.json, state.json under projectDir, not contentDir', async () => {const projectDir = mkdtempSync(resolve(tmpDir, 'fake-repo-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);seedOkScaffold(projectDir);const contentDir = resolve(projectDir, 'template-projects');mkdirSync(contentDir, { recursive: true });@@ -226,6 +233,7 @@ describe('bootServer — tolerance-telemetry writer wired through the real bootprocess.env.OK_BRIDGE_TOLERANCE_TELEMETRY = '1';const projectDir = mkdtempSync(resolve(tmpDir, 'tolerance-telemetry-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);seedOkScaffold(projectDir);const booted = await bootServer({@@ -259,6 +267,7 @@ describe('bootServer — idle-shutdown runs full destroy', () => {test('after idle-shutdown fires with zero WS clients, httpServer is no longer listening', async () => {const projectDir = mkdtempSync(resolve(tmpDir, 'idle-full-destroy-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);seedOkScaffold(projectDir);const booted = await bootServer({@@ -289,6 +298,7 @@ describe('bootServer — reactShellDistDir + server.lock ui advertisement', () =test('server.lock advertises the ui capability when --react-shell-dist-dir is set', async () => {const projectDir = mkdtempSync(resolve(tmpDir, 'fake-repo-shell-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);seedOkScaffold(projectDir);const shellDistDir = mkdtempSync(resolve(tmpDir, 'fake-shell-dist-'));@@ -322,6 +332,7 @@ describe('bootServer — reactShellDistDir + server.lock ui advertisement', () =test('server.lock omits the ui capability when reactShellDistDir is absent (CLI default)', async () => {const projectDir = mkdtempSync(resolve(tmpDir, 'fake-repo-no-shell-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);seedOkScaffold(projectDir);const booted = await bootServer({@@ -350,6 +361,7 @@ describe('bootServer — reactShellDistDir end-to-end HTTP shape', () => {test('serves the React shell, bundled assets, content assets, and API on one port', async () => {const projectDir = mkdtempSync(resolve(tmpDir, 'shell-e2e-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);seedOkScaffold(projectDir);const shellDistDir = mkdtempSync(resolve(tmpDir, 'shell-e2e-dist-'));@@ -566,6 +578,7 @@ describe('bootServer — ok.boot OTel span attributes', () => {test('main worktree: ok.boot span has worktree.kind=main', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'span-main-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);const booted = await bootServer({@@ -593,6 +606,7 @@ describe('bootServer — ok.boot OTel span attributes', () => {test('linked worktree: ok.boot span has worktree.kind=linked', async () => {const repoRoot = mkdtempSync(resolve(tmpDir, 'span-linked-repo-'));await execFileAsync('git', ['init', '--initial-branch=main', repoRoot]);+ configureTestGitRepository(repoRoot);await execFileAsync('git', ['-C', repoRoot, 'config', 'user.email', '[email protected]']);await execFileAsync('git', ['-C', repoRoot, 'config', 'user.name', 'Test']);writeFileSync(resolve(repoRoot, 'README.md'), '# test\n');@@ -637,6 +651,7 @@ describe('bootServer — ok.boot OTel span attributes', () => {test('boot failure (MissingOkConfigError): span still records the worktree kind', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'span-fail-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);let caught: unknown;try {@@ -663,6 +678,7 @@ describe('bootServer — ok.boot OTel span attributes', () => {test('cross-invocation: main first, linked second — kinds flip correctly with no state leakage', async () => {const mainDir = mkdtempSync(resolve(tmpDir, 'flip-main-'));await execFileAsync('git', ['init', '--initial-branch=main', mainDir]);+ configureTestGitRepository(mainDir);seedOkScaffold(mainDir);const bootedMain = await bootServer({host: '127.0.0.1',@@ -677,6 +693,7 @@ describe('bootServer — ok.boot OTel span attributes', () => {const repoRoot = mkdtempSync(resolve(tmpDir, 'flip-linked-repo-'));await execFileAsync('git', ['init', '--initial-branch=main', repoRoot]);+ configureTestGitRepository(repoRoot);await execFileAsync('git', ['-C', repoRoot, 'config', 'user.email', '[email protected]']);await execFileAsync('git', ['-C', repoRoot, 'config', 'user.name', 'Test']);writeFileSync(resolve(repoRoot, 'README.md'), '# test\n');@@ -723,6 +740,7 @@ describe('bootServer — ok.boot OTel span attributes', () => {propagation.setGlobalPropagator(new W3CTraceContextPropagator());const contentDir = mkdtempSync(resolve(tmpDir, 'traceparent-valid-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);let booted: Awaited<ReturnType<typeof bootServer>> | null = null;@@ -751,6 +769,7 @@ describe('bootServer — ok.boot OTel span attributes', () => {process.env.OK_STARTUP_TRACEPARENT = 'not-a-valid-traceparent';const contentDir = mkdtempSync(resolve(tmpDir, 'traceparent-malformed-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);let booted: Awaited<ReturnType<typeof bootServer>> | null = null;@@ -780,6 +799,7 @@ describe('bootServer — boot timings recorded end-to-end', () => {test('a full boot populates httpListen / seedWalk / indexes / ready / fileCount', async () => {const projectDir = mkdtempSync(resolve(tmpDir, 'boot-timings-e2e-'));await execFileAsync('git', ['init', '--initial-branch=main', projectDir]);+ configureTestGitRepository(projectDir);seedOkScaffold(projectDir);writeFileSync(resolve(projectDir, 'note.md'), '# note\n', 'utf-8');@@ -873,6 +893,7 @@ describe('bootServer — exposure consent interlock', () => {): Promise<unknown> {const contentDir = mkdtempSync(resolve(tmpDir, 'interlock-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);const config = ConfigSchema.parse({ server });try {@@ -940,6 +961,7 @@ describe('bootServer — exposure consent interlock', () => {test('a non-loopback host with no bind/serverRuntime still trips the interlock (single-file shape)', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'interlock-host-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);let err: unknown = null;try {@@ -966,6 +988,7 @@ describe('bootServer — multi-address bind', () => {test('every bind address answers on the same port; teardown closes all listeners', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'multibind-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);const booted = await bootServer({host: '127.0.0.1',@@ -993,6 +1016,7 @@ describe('bootServer — multi-address bind', () => {test('the listen record names the bound port, pid and every address, and agrees with the lock', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'listenlog-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);const entries: Array<{ fields: Record<string, unknown>; msg: string }> = [];const noop = (): void => {};@@ -1041,6 +1065,7 @@ describe('bootServer — multi-address bind', () => {test('duplicate bind entries collapse instead of failing with EADDRINUSE', async () => {const contentDir = mkdtempSync(resolve(tmpDir, 'multibind-dup-'));await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);const booted = await bootServer({host: '127.0.0.1',diff --git a/packages/server/src/checkpoint-chain.test.ts b/packages/server/src/checkpoint-chain.test.tsindex 29933d0a5..0c759d2a8 100644--- a/packages/server/src/checkpoint-chain.test.ts+++ b/packages/server/src/checkpoint-chain.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { resolveCheckpointChainAnchors } from './checkpoint-chain.ts';import {initShadowRepo,@@ -22,6 +23,7 @@ beforeEach(async () => {mkdirSync(resolve(projectRoot, 'content/docs'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);diff --git a/packages/server/src/checkpoint-restore-floor.test.ts b/packages/server/src/checkpoint-restore-floor.test.tsindex 9fe70ac70..f19a77046 100644--- a/packages/server/src/checkpoint-restore-floor.test.ts+++ b/packages/server/src/checkpoint-restore-floor.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { extensionlessDocTreePath } from './doc-extensions.ts';import {batchCheckExistence,@@ -46,6 +47,7 @@ async function setup(): Promise<{ contentDir: string; shadow: ShadowHandle }> {mkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(contentDir, 'intro.md'), '# Hello\n');diff --git a/packages/server/src/checkpoint-retention-tie.test.ts b/packages/server/src/checkpoint-retention-tie.test.tsindex 8a5d82998..6af271d6a 100644--- a/packages/server/src/checkpoint-retention-tie.test.ts+++ b/packages/server/src/checkpoint-retention-tie.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {DEFAULT_CHECKPOINT_RETENTION,gcCheckpointRefs,@@ -22,6 +23,7 @@ beforeEach(async () => {mkdirSync(resolve(projectRoot, 'content/docs'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);diff --git a/packages/server/src/conflict-authority.test.ts b/packages/server/src/conflict-authority.test.tsindex 6b5c28be5..49411578c 100644--- a/packages/server/src/conflict-authority.test.ts+++ b/packages/server/src/conflict-authority.test.ts@@ -15,6 +15,7 @@ import { LOCAL_DIR } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {bindConflictAuthority,ConflictAuthority,@@ -974,6 +975,7 @@ describe('ConflictAuthority working-tree resolve against a real repo', () => {): Promise<{ blobSha: string; headSha: string }> {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, file), remote, 'utf-8');@@ -1124,6 +1126,7 @@ describe('ConflictAuthority resolve refuses markers on every strategy', () => {test("a working-tree 'theirs' whose pinned blob carries markers is refused before the write", async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'a.md'), MARKERED, 'utf-8');diff --git a/packages/server/src/content-filter.test.ts b/packages/server/src/content-filter.test.tsindex 5b9c794e5..02abd1334 100644--- a/packages/server/src/content-filter.test.ts+++ b/packages/server/src/content-filter.test.ts@@ -13,6 +13,7 @@ import {} from '@opentelemetry/sdk-trace-base';import ignore from 'ignore';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {type ContentFilter,createContentFilter,@@ -214,6 +215,7 @@ describe('ContentFilter', () => {describe('git-extras ignore sources', () => {function initGitRepo(dir: string): void {execFileSync('git', ['init', '-q'], { cwd: dir });+ configureTestGitRepository(dir);}test('excludes paths matched by .git/info/exclude (per-clone, untracked)', () => {@@ -387,6 +389,7 @@ describe('ContentFilter', () => {test('drops blanket .ok globs so the OS watcher can reach .ok/skills (skills-as-content)', () => {execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);writeFileSync(join(projectDir, '.git', 'info', 'exclude'), '.ok/\n');writeFileSync(join(projectDir, '.gitignore'), 'dist/\n.ok\nnode_modules/\n');@@ -410,6 +413,7 @@ describe('ContentFilter', () => {test('drops the children-exclude the skills-sharing carve writes (sync)', () => {execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);writeFileSync(join(projectDir, '.git', 'info', 'exclude'), '**/.ok/*\n!**/.ok/skills/\n');writeFileSync(join(projectDir, '.gitignore'), 'dist/\n');const filter = createContentFilter({ projectDir, contentDir: projectDir });@@ -417,6 +421,7 @@ describe('ContentFilter', () => {});test('drops the children-exclude the skills-sharing carve writes (async)', async () => {execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);writeFileSync(join(projectDir, '.git', 'info', 'exclude'), '**/.ok/*\n!**/.ok/skills/\n');writeFileSync(join(projectDir, '.gitignore'), 'dist/\n');const filter = await createContentFilterAsync({ projectDir, contentDir: projectDir });@@ -487,6 +492,7 @@ describe('ContentFilter', () => {'dist/\nnode_modules/**\ndocs/.ok/templates/\npackages/app/.ok/templates/\n.*\n.ok\n.ok/**\n.ok/**/*\n**/.ok\n**/.ok/**\n**/.ok/**/*\n.ok/*\n**/.ok/*\n.ok/templates/\n.ok/local\n.ok/local/**\n.ok/local/../templates\nnode_modules/../docs\n',);execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);writeFileSync(join(projectDir, '.git', 'info', 'exclude'), '.ok/\n');const filter = createContentFilter({ projectDir, contentDir: projectDir });assertShareableOkLeavesUnblocked(filter);@@ -497,6 +503,7 @@ describe('ContentFilter', () => {'dist/\nnode_modules/**\ndocs/.ok/templates/\npackages/app/.ok/templates/\n.*\n.ok\n.ok/**\n.ok/**/*\n**/.ok\n**/.ok/**\n**/.ok/**/*\n.ok/*\n**/.ok/*\n.ok/templates/\n.ok/local\n.ok/local/**\n.ok/local/../templates\nnode_modules/../docs\n',);execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);writeFileSync(join(projectDir, '.git', 'info', 'exclude'), '.ok/\n');const filter = await createContentFilterAsync({ projectDir, contentDir: projectDir });assertShareableOkLeavesUnblocked(filter);diff --git a/packages/server/src/content/enrichment.test.ts b/packages/server/src/content/enrichment.test.tsindex f17ed9350..42792e666 100644--- a/packages/server/src/content/enrichment.test.ts+++ b/packages/server/src/content/enrichment.test.ts@@ -6,6 +6,7 @@ import { okfAdvertisedSchemaMappings } from '@inkeep/open-knowledge-core';import { commitWip, initShadowRepo, type WriterIdentity } from '@inkeep/open-knowledge-server';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {computeGraphRole,enrichDirectory,@@ -28,6 +29,7 @@ async function bootstrapProject(): Promise<string> {mkdirSync(project, { recursive: true });const git = simpleGit(project);await git.init();+ configureTestGitRepository(project);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(project, 'README.md'), '# root\n');diff --git a/packages/server/src/content/generated-index-git-attributes.test.ts b/packages/server/src/content/generated-index-git-attributes.test.tsindex 357462eb6..b69a1a8e9 100644--- a/packages/server/src/content/generated-index-git-attributes.test.ts+++ b/packages/server/src/content/generated-index-git-attributes.test.ts@@ -9,6 +9,7 @@ import {} from 'node:fs';import { join } from 'node:path';import { afterAll, afterEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { createTempDirFactory } from '../../../../test-support/temp-dir.test-helper.ts';import { getLogger } from '../logger.ts';import {@@ -23,6 +24,7 @@ afterEach(() => vi.restoreAllMocks());function makeProject(contentSubdir = '.'): { projectDir: string; contentDir: string } {const projectDir = makeTempDir('ok-generated-index-attrs-');execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);if (contentSubdir !== '.') mkdirSync(join(projectDir, contentSubdir), { recursive: true });return {projectDir,diff --git a/packages/server/src/content/shadow-log.test.ts b/packages/server/src/content/shadow-log.test.tsindex f2c0f3f8e..024575775 100644--- a/packages/server/src/content/shadow-log.test.ts+++ b/packages/server/src/content/shadow-log.test.ts@@ -6,6 +6,7 @@ import { setTimeout as wait } from 'node:timers/promises';import { formatOkActor, type OkActorEntry } from '@inkeep/open-knowledge-core/shadow-repo-layout';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {commitUpstreamImport,commitWip,@@ -48,6 +49,7 @@ async function bootstrapProject(): Promise<string> {mkdirSync(project, { recursive: true });const git = simpleGit(project);await git.init();+ configureTestGitRepository(project);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(project, 'README.md'), '# root\n');diff --git a/packages/server/src/derive-fixed-point-backstop.test.ts b/packages/server/src/derive-fixed-point-backstop.test.tsindex 02d4f30d1..ea130eb8e 100644--- a/packages/server/src/derive-fixed-point-backstop.test.ts+++ b/packages/server/src/derive-fixed-point-backstop.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createBridgeRaceRig } from './bridge-race-rig.test-helper.ts';import { LOSS_EVENT_BACKSTOP_TRIP, type LossCaptureEventInput } from './loss-capture.ts';import { getMetrics } from './metrics.ts';@@ -293,6 +294,7 @@ describe('re-derive fixed-point backstop — checkpoint floor', () => {mkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(contentDir, 'backstop.md'), '# Seed\n');diff --git a/packages/server/src/derive-timing-exhaustion.test.ts b/packages/server/src/derive-timing-exhaustion.test.tsindex 28c018689..fae451d45 100644--- a/packages/server/src/derive-timing-exhaustion.test.ts+++ b/packages/server/src/derive-timing-exhaustion.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { type BridgeRaceRig, createBridgeRaceRig } from './bridge-race-rig.test-helper.ts';import type { LossCaptureEventInput } from './loss-capture.ts';import { getMetrics } from './metrics.ts';@@ -139,6 +140,7 @@ describe('derive-timing defer exhaustion — checkpoint floor', () => {mkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(contentDir, 'exhaustion.md'), '# Seed\n');diff --git a/packages/server/src/git-branch-info.test.ts b/packages/server/src/git-branch-info.test.tsindex 298f8ac3e..8adbe9bcf 100644--- a/packages/server/src/git-branch-info.test.ts+++ b/packages/server/src/git-branch-info.test.ts@@ -1,12 +1,11 @@import { afterEach, describe, expect, test } from 'vitest';-+import { createGitTriangle, type GitTriangle } from '../tests/support/git-fixture.test-helper.ts';import {computeBranchInfo,isBranchResolutionError,isValidBranchInfoPath,isValidBranchName,} from './git-branch-info.ts';-import { createGitTriangle, type GitTriangle } from './share/git-fixture.test-helper.ts';describe('isValidBranchName', () => {test('accepts a plain branch name', () => {diff --git a/packages/server/src/git-checkout-symlink-check-failure.test.ts b/packages/server/src/git-checkout-symlink-check-failure.test.tsindex fb30c5a96..196fe78a6 100644--- a/packages/server/src/git-checkout-symlink-check-failure.test.ts+++ b/packages/server/src/git-checkout-symlink-check-failure.test.ts@@ -3,6 +3,7 @@ import { mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';vi.mock('./incoming-symlink-guard.ts', async (importOriginal) => {const actual = await importOriginal<typeof import('./incoming-symlink-guard.ts')>();@@ -41,7 +42,9 @@ describe('share-link branch switch when the symlink check cannot run', () => {const seedDir = join(tmpDir, 'seed');projectDir = join(tmpDir, 'project');git(tmpDir, 'init', '-q', '--bare', '--initial-branch=main', bareDir);+ configureTestGitRepository(bareDir);git(tmpDir, 'init', '-q', '--initial-branch=main', seedDir);+ configureTestGitRepository(seedDir);writeFileSync(join(seedDir, 'a.md'), '# A\n');git(seedDir, 'add', 'a.md');git(seedDir, 'commit', '-q', '-m', 'base');@@ -53,6 +56,7 @@ describe('share-link branch switch when the symlink check cannot run', () => {git(seedDir, 'commit', '-q', '-m', 'shared');git(seedDir, 'push', '-q', 'origin', 'shared');git(tmpDir, 'clone', '-q', bareDir, projectDir);+ configureTestGitRepository(projectDir);});afterEach(() => {diff --git a/packages/server/src/git-checkout.test.ts b/packages/server/src/git-checkout.test.tsindex 97caf8dfb..f41e56083 100644--- a/packages/server/src/git-checkout.test.ts+++ b/packages/server/src/git-checkout.test.ts@@ -4,7 +4,8 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { promisify } from 'node:util';import { afterEach, describe, expect, test } from 'vitest';-+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';+import { createGitTriangle, type GitTriangle } from '../tests/support/git-fixture.test-helper.ts';import {fastForwardBranchToOrigin,isBranchInOtherWorktreeError,@@ -12,7 +13,6 @@ import {runCheckoutFlow,} from './git-checkout.ts';import { createGitInstance } from './git-handle.ts';-import { createGitTriangle, type GitTriangle } from './share/git-fixture.test-helper.ts';const execFileAsync = promisify(execFile);@@ -178,6 +178,7 @@ describe('runCheckoutFlow against real git', () => {const main = join(root, 'main');mkdirSync(main);await git(main, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(main);await git(main, 'config', 'user.email', '[email protected]');await git(main, 'config', 'user.name', 'Test');writeFileSync(join(main, 'README.md'), '# main\n');@@ -202,6 +203,7 @@ describe('runCheckoutFlow against real git', () => {try {const main = root;await git(main, 'init', '--initial-branch=main', '.');+ configureTestGitRepository(main);await git(main, 'config', 'user.email', '[email protected]');await git(main, 'config', 'user.name', 'Test');writeFileSync(join(main, 'README.md'), '# main\n');diff --git a/packages/server/src/git-dirty.test.ts b/packages/server/src/git-dirty.test.tsindex 32eef92d8..5f67ce3ee 100644--- a/packages/server/src/git-dirty.test.ts+++ b/packages/server/src/git-dirty.test.ts@@ -3,6 +3,7 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { dirtyFilesOverlapWith } from './git-dirty.ts';let projectDir: string;@@ -22,6 +23,7 @@ function commitAll(message: string): void {function initRepo(): void {run('git init -q -b main');+ configureTestGitRepository(projectDir);run('git config user.email "[email protected]"');run('git config user.name "Test"');run('git config commit.gpgsign false');diff --git a/packages/server/src/git-handle.test.ts b/packages/server/src/git-handle.test.tsindex c0575e638..c35470c1a 100644--- a/packages/server/src/git-handle.test.ts+++ b/packages/server/src/git-handle.test.ts@@ -8,6 +8,7 @@ import { setTimeout as wait } from 'node:timers/promises';import { DESKTOP_PRODUCTS, resolveDesktopProductName } from '@inkeep/open-knowledge-core';import shellQuote from 'shell-quote';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {applyGitEnv,buildGitEnv,@@ -128,6 +129,7 @@ describe('createGitInstance (credential.helper config)', () => {beforeEach(() => {tmpDir = mkdtempSync(join(tmpdir(), 'ok-git-handle-test-'));execSync('git init -q', { cwd: tmpDir });+ configureTestGitRepository(tmpDir);});afterEach(() => {@@ -200,6 +202,7 @@ describe('createGitInstance under a process environment carrying GIT_CONFIG_COUNvi.stubEnv('USERPROFILE', isolatedHome);vi.stubEnv('XDG_CONFIG_HOME', join(isolatedHome, '.config'));execSync('git init -q', { cwd: repoDir });+ configureTestGitRepository(repoDir);vi.stubEnv('GIT_CONFIG_COUNT', '1');vi.stubEnv('GIT_CONFIG_KEY_0', 'credential.interactive');vi.stubEnv('GIT_CONFIG_VALUE_0', 'false');@@ -230,6 +233,7 @@ describe.skipIf(process.platform === 'win32')(repoDir = mkdtempSync(join(tmpdir(), 'ok-sync-cred-repo-'));isolatedHome = mkdtempSync(join(tmpdir(), 'ok-sync-cred-home-'));execSync('git init -q', { cwd: repoDir });+ configureTestGitRepository(repoDir);});afterEach(() => {diff --git a/packages/server/src/git-identity.includes.test.ts b/packages/server/src/git-identity.includes.test.tsindex 304b2143e..2468b2c64 100644--- a/packages/server/src/git-identity.includes.test.ts+++ b/packages/server/src/git-identity.includes.test.ts@@ -3,6 +3,7 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { basename, join } from 'node:path';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { resolveGitIdentity } from './git-identity.ts';@@ -38,6 +39,7 @@ describe('resolveGitIdentity with included git config', () => {writeFileSync(identityFile, '[user]\n\tname = Included Dev\n\temail = [email protected]\n');expect(run(tmp, 'init', '-b', 'main', 'repo').status).toBe(0);+ configureTestGitRepository(repo);});afterEach(() => {diff --git a/packages/server/src/git-identity.worktree.test.ts b/packages/server/src/git-identity.worktree.test.tsindex 227ccde92..4841ae8da 100644--- a/packages/server/src/git-identity.worktree.test.ts+++ b/packages/server/src/git-identity.worktree.test.ts@@ -3,6 +3,7 @@ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'noimport { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { resolveGitIdentity, writeGitIdentity } from './git-identity.ts';@@ -43,6 +44,7 @@ function setupRepo(): { tmp: string; main: string; linked: string } {const linked = join(tmp, 'wt');expect(run(tmp, 'init', '-b', 'main', 'repo').status).toBe(0);+ configureTestGitRepository(main);expect(run(main, 'config', 'user.email', '[email protected]').status).toBe(0);expect(run(main, 'config', 'user.name', 'Main Test').status).toBe(0);writeFileSync(join(main, 'a.txt'), 'hi\n');diff --git a/packages/server/src/git-paths.test.ts b/packages/server/src/git-paths.test.tsindex 97453a0ae..ef2e8c5e9 100644--- a/packages/server/src/git-paths.test.ts+++ b/packages/server/src/git-paths.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {listNameStatus,listNames,@@ -157,6 +158,7 @@ describe('path-listing wrappers (real git)', () => {beforeEach(() => {projectDir = mkdtempSync(join(tmpdir(), 'ok-git-paths-test-'));run('git init -q -b main');+ configureTestGitRepository(projectDir);run('git config user.email "[email protected]"');run('git config user.name "Test"');run('git config commit.gpgsign false');diff --git a/packages/server/src/git-pathspec-name-invariance.test.ts b/packages/server/src/git-pathspec-name-invariance.test.tsindex 2794a9a54..9d498ae2b 100644--- a/packages/server/src/git-pathspec-name-invariance.test.ts+++ b/packages/server/src/git-pathspec-name-invariance.test.ts@@ -6,6 +6,8 @@ import { join, resolve } from 'node:path';import { LOCAL_DIR } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';+import { createGitTriangle, type GitTriangle } from '../tests/support/git-fixture.test-helper.ts';import { renameTrackedPathInGit } from './api-extension.ts';import { ConflictAuthority } from './conflict-authority.ts';import { readProjectGitLog } from './content/project-log.ts';@@ -20,7 +22,6 @@ import {type WriterIdentity,} from './shadow-repo.ts';import { computeShareFreshness } from './share/freshness.ts';-import { createGitTriangle, type GitTriangle } from './share/git-fixture.test-helper.ts';import { computeShareTargetStatus } from './share/target-status.ts';import { restoreSkillVersion } from './skill-restore.ts';import { SyncEngine } from './sync-engine.ts';@@ -101,10 +102,12 @@ async function initProjectWithBareRemote(): Promise<string> {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const g = simpleGit(projectDir);await g.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await g.raw('config', 'user.name', 'Test');await g.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# seed\n', 'utf-8');@@ -282,12 +285,14 @@ describe('pathspec name invariance — commitBlockingPaths (site 3)', () => {mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const sisterDir = join(tmpDir, 'sister');mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, BLOCKING_NAME), '{"a":1}\n', 'utf-8');@@ -299,6 +304,7 @@ describe('pathspec name invariance — commitBlockingPaths (site 3)', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);await project.raw('config', 'user.name', 'Project');@@ -345,6 +351,7 @@ describe('pathspec name invariance — shadow-repo per-path history (sites 9, 10async function shadowWithBothDocs(): Promise<{ shadow: ShadowHandle; wipSha: string }> {const g = simpleGit(projectDir);await g.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await g.raw('config', 'user.name', 'Test');await g.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# seed\n', 'utf-8');@@ -426,12 +433,14 @@ describe('pathspec name invariance — non-content merge auto-resolve (site 5)',mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const sisterDir = join(tmpDir, 'sister');mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, fileName), '{"a":1}\n', 'utf-8');@@ -443,6 +452,7 @@ describe('pathspec name invariance — non-content merge auto-resolve (site 5)',rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);await project.raw('config', 'user.name', 'Project');@@ -500,10 +510,12 @@ describe('pathspec name invariance — pull-only overlay restore (site 6)', () =const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, docName), 'v1\n', 'utf-8');@@ -513,6 +525,7 @@ describe('pathspec name invariance — pull-only overlay restore (site 6)', () =await sister.push('origin', 'main');await simpleGit(root).clone(bareDir, cloneDir);+ configureTestGitRepository(cloneDir);mkdirSync(join(cloneDir, '.ok', LOCAL_DIR), { recursive: true });const project = simpleGit(cloneDir);await project.raw('config', 'user.name', 'Project');@@ -601,6 +614,7 @@ describe('pathspec argv sites with no product-producible hostile input today', (test('restoring a wildcard-named skill restores only its own files', async () => {const g = simpleGit(projectDir);await g.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await g.raw('config', 'user.name', 'Test');await g.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# seed\n', 'utf-8');diff --git a/packages/server/src/git-worktree-status.test.ts b/packages/server/src/git-worktree-status.test.tsindex 76f60d344..dfc2e36ff 100644--- a/packages/server/src/git-worktree-status.test.ts+++ b/packages/server/src/git-worktree-status.test.ts@@ -14,6 +14,7 @@ import { delimiter, join } from 'node:path';import type { GitWorktreeOpenTarget } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import type { PorcelainEntry } from './git-paths.ts';import { parsePorcelainEntries } from './git-paths.ts';import {@@ -212,11 +213,13 @@ describe('readIncomingEntries', () => {async function projectBehindOrigin() {const bare = join(dir, 'bare.git');await simpleGit().init(true, [bare]);+ configureTestGitRepository(bare);await simpleGit(bare).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const project = join(dir, 'project');const git = simpleGit();await git.clone(bare, project);+ configureTestGitRepository(project);const pg = simpleGit(project);await pg.raw('config', 'user.name', 'Test');await pg.raw('config', 'user.email', '[email protected]');@@ -227,6 +230,7 @@ describe('readIncomingEntries', () => {const sister = join(dir, 'sister');await simpleGit().clone(bare, sister);+ configureTestGitRepository(sister);const sg = simpleGit(sister);await sg.raw('config', 'user.name', 'Sister');await sg.raw('config', 'user.email', '[email protected]');@@ -280,6 +284,7 @@ describe('readIncomingEntries', () => {const solo = join(dir, 'solo');const git = simpleGit();await git.init(false, [solo]);+ configureTestGitRepository(solo);const sg = simpleGit(solo);await sg.raw('config', 'user.name', 'Test');await sg.raw('config', 'user.email', '[email protected]');@@ -337,6 +342,7 @@ describe('readWorktreeStatus open-target stamping', () => {const project = join(dir, 'project');const git = simpleGit();await git.init(false, [project]);+ configureTestGitRepository(project);const pg = simpleGit(project);await pg.raw('config', 'user.name', 'Test');await pg.raw('config', 'user.email', '[email protected]');@@ -360,6 +366,7 @@ describe('readWorktreeStatus open-target stamping', () => {test('omits every open target when no mapper is supplied', async () => {const project = join(dir, 'project');await simpleGit().init(false, [project]);+ configureTestGitRepository(project);const pg = simpleGit(project);await pg.raw('config', 'user.name', 'Test');await pg.raw('config', 'user.email', '[email protected]');@@ -395,6 +402,7 @@ describe('readWorktreeStatus — an unreadable tree is representable', () => {test('a real repo reports readable: true', async () => {const g = simpleGit(dir);await g.init(['--initial-branch=main']);+ configureTestGitRepository(dir);await g.raw('config', 'user.email', '[email protected]');await g.raw('config', 'user.name', 'T');writeFileSync(join(dir, 'a.md'), 'x\n');@@ -420,6 +428,7 @@ describe('readWorktreeStatus — the panel listing is trustworthy', () => {mkdirSync(project, { recursive: true });const g = simpleGit(project);await g.init(['--initial-branch=main']);+ configureTestGitRepository(project);await g.raw('config', 'user.name', 'Test');await g.raw('config', 'user.email', '[email protected]');writeFileSync(join(project, 'seed.md'), 'v1\n');@@ -474,6 +483,7 @@ describe('readWorktreeStatus — the panel listing is trustworthy', () => {const bare = join(dir, 'bare.git');mkdirSync(bare, { recursive: true });await simpleGit(bare).init(true);+ configureTestGitRepository(bare);await simpleGit(bare).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const g = simpleGit(project);await g.addRemote('origin', bare);@@ -620,6 +630,7 @@ describe('readWorktreeStatus — the panel listing is trustworthy', () => {mkdirSync(project, { recursive: true });const g = simpleGit(project);await g.init(['--initial-branch=main']);+ configureTestGitRepository(project);writeFileSync(join(project, 'a.md'), 'x\n');const logger = getLogger('git-worktree-status');const warned: Record<string, unknown>[] = [];diff --git a/packages/server/src/github-account-agreement.test.ts b/packages/server/src/github-account-agreement.test.tsindex 4f45c3bf2..53f3306e9 100644--- a/packages/server/src/github-account-agreement.test.ts+++ b/packages/server/src/github-account-agreement.test.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import { LOCAL_DIR } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createTestConflictAuthority } from './conflict-authority.test-helper.ts';import type { GitHandle } from './git-handle.ts';import {@@ -42,6 +43,7 @@ afterEach(() => {async function initGitWithOrigin(originUrl: string): Promise<void> {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), 'seed\n', 'utf-8');diff --git a/packages/server/src/http/local-op-routes.test.ts b/packages/server/src/http/local-op-routes.test.tsindex e582b62be..1bafc36a1 100644--- a/packages/server/src/http/local-op-routes.test.ts+++ b/packages/server/src/http/local-op-routes.test.ts@@ -4,6 +4,7 @@ import { createServer, type Server as HttpServer } from 'node:http';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { createConcurrencyGuard } from '../local-op-security.ts';import * as ghLogin from '../local-ops/gh-login.ts';import type { AuthEvent } from '../local-ops/types.ts';@@ -230,6 +231,7 @@ describe('auth-login stream displacement (a second start orphans the first clienconst projectDir = mkdtempSync(join(tmpdir(), 'ok-local-op-non-github-'));try {execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);execFileSync('git', ['remote', 'add', 'origin', 'https://git.example.internal/team/kb.git'], {cwd: projectDir,});@@ -272,6 +274,7 @@ describe('auth-login stream displacement (a second start orphans the first clienvi.stubEnv('USERPROFILE', home);try {execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);execFileSync('git', ['remote', 'add', 'origin', 'https://git.example.internal/team/kb.git'], {cwd: projectDir,});@@ -378,6 +381,7 @@ describe('auth-login stream displacement (a second start orphans the first clienconst projectDir = mkdtempSync(join(tmpdir(), 'ok-unparseable-origin-'));try {execFileSync('git', ['init', '-q'], { cwd: projectDir });+ configureTestGitRepository(projectDir);execFileSync('git', ['remote', 'add', 'origin', '../other-repository'], { cwd: projectDir });const baseUrl = await serveLocalOpGroup({ projectDir });const response = await postJson(baseUrl, '/api/local-op/auth/status', {});diff --git a/packages/server/src/http/share-routes.test.ts b/packages/server/src/http/share-routes.test.tsindex 68059a221..44d518927 100644--- a/packages/server/src/http/share-routes.test.ts+++ b/packages/server/src/http/share-routes.test.ts@@ -6,6 +6,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { Readable } from 'node:stream';import { afterEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { makeCaptureRes, makeSyntheticReq } from '../composition-rig.test-helper.ts';import { loggerFactory } from '../logger.ts';import { useIsolatedHome } from '../share/git-host-declarations.test-helper.ts';@@ -85,6 +86,7 @@ describe('createShareRoutes table', () => {const git = (...args: string[]) => execFileSync('git', args, { cwd: projectDir });try {git('init', '--initial-branch=main');+ configureTestGitRepository(projectDir);git('remote', 'add', 'origin', 'https://ghes.example.com/team/kb.git');mkdirSync(join(home(), '.ok'));const config = join(home(), '.ok', 'global.yml');diff --git a/packages/server/src/http/sync-routes.test.ts b/packages/server/src/http/sync-routes.test.tsindex e8130e7b3..74d59faff 100644--- a/packages/server/src/http/sync-routes.test.ts+++ b/packages/server/src/http/sync-routes.test.ts@@ -6,6 +6,7 @@ import { Readable } from 'node:stream';import { Hocuspocus } from '@hocuspocus/server';import simpleGit from 'simple-git';import { afterAll, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import { createTempDirFactory } from '../../../../test-support/temp-dir.test-helper.ts';import { makeCaptureRes, makeSyntheticReq } from '../composition-rig.test-helper.ts';import { createTestConflictAuthority } from '../conflict-authority.test-helper.ts';@@ -372,6 +373,7 @@ describe('conflict-content dispatches per conflict kind', () => {try {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'a.md'), 'tracked\n', 'utf-8');diff --git a/packages/server/src/incident-replay.test.ts b/packages/server/src/incident-replay.test.tsindex 4230c3b9d..d05bed95d 100644--- a/packages/server/src/incident-replay.test.ts+++ b/packages/server/src/incident-replay.test.ts@@ -12,6 +12,7 @@ import {} from '@opentelemetry/sdk-metrics';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createMaintenanceCoordinator } from './maintenance-coordinator.ts';import {__resetMaintenanceTelemetryForTesting,@@ -162,6 +163,7 @@ describe('PRD-6972 incident replay — storyline from telemetry + diagnose reademkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'T');await git.raw('config', 'user.email', 't@t');writeFileSync(resolve(contentDir, 'intro.md'), '# h\n');@@ -246,6 +248,7 @@ describe('gc.log latch counter measures distinct episodes, not observations', ()mkdirSync(projectRoot, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'T');await git.raw('config', 'user.email', 't@t');writeFileSync(resolve(projectRoot, 'r.md'), '# h\n');diff --git a/packages/server/src/maintenance-consolidation.test.ts b/packages/server/src/maintenance-consolidation.test.tsindex 0134d6207..a53cb30de 100644--- a/packages/server/src/maintenance-consolidation.test.ts+++ b/packages/server/src/maintenance-consolidation.test.ts@@ -3,6 +3,7 @@ import { resolve } from 'node:path';import { parseCheckpoint } from '@inkeep/open-knowledge-core/shadow-repo-layout';import simpleGit from 'simple-git';import { afterAll, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createTempDirFactory } from '../../../test-support/temp-dir.test-helper.ts';import { createMaintenanceCoordinator } from './maintenance-coordinator.ts';import { commitWip, initShadowRepo, type ShadowHandle, shadowGit } from './shadow-repo.ts';@@ -23,6 +24,7 @@ beforeEach(async () => {mkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(contentDir, 'intro.md'), '# Hello\n');diff --git a/packages/server/src/maintenance-coordinator.test.ts b/packages/server/src/maintenance-coordinator.test.tsindex 7f3ce3fb3..8bdcaae6e 100644--- a/packages/server/src/maintenance-coordinator.test.ts+++ b/packages/server/src/maintenance-coordinator.test.ts@@ -5,6 +5,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {createMaintenanceCoordinator,FLUSH_GC_INTERVAL,@@ -34,6 +35,7 @@ beforeEach(async () => {mkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(contentDir, 'intro.md'), '# Hello\n');diff --git a/packages/server/src/mcp/tools/exec.test.ts b/packages/server/src/mcp/tools/exec.test.tsindex b42a34a65..7c0b88355 100644--- a/packages/server/src/mcp/tools/exec.test.ts+++ b/packages/server/src/mcp/tools/exec.test.ts@@ -5,6 +5,7 @@ import { resolve } from 'node:path';import { commitWip, initShadowRepo, type WriterIdentity } from '@inkeep/open-knowledge-server';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../../test-support/configure-git-fixture.test-helper.ts';import { type Config, ConfigSchema } from '../../config/schema.ts';import type { DirectoryMeta, EnrichedMeta } from '../../content/enrichment.ts';import {@@ -63,6 +64,7 @@ async function bootstrap(): Promise<string> {mkdirSync(project, { recursive: true });const git = simpleGit(project);await git.init();+ configureTestGitRepository(project);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(project, 'README.md'), '# probe\n');diff --git a/packages/server/src/parcel-drop-notice.test.ts b/packages/server/src/parcel-drop-notice.test.tsindex ade5b2c76..fd63039bb 100644--- a/packages/server/src/parcel-drop-notice.test.ts+++ b/packages/server/src/parcel-drop-notice.test.ts@@ -20,6 +20,7 @@ import { tmpdir } from 'node:os';import { basename, dirname, join } from 'node:path';import type { Event } from '@parcel/watcher';import { afterEach, beforeEach, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { bootCompositionRig } from './composition-rig.test-helper.ts';import {type ContentFilter,@@ -1373,6 +1374,7 @@ function prepareSkillServerProject(ledgerValue: unknown): { home: string; ledgercwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);return { home, ledger };}@@ -1928,6 +1930,7 @@ test('server startup and raw skill refresh retain admission across an unreadablecwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);let server: ServerInstance | undefined;let connection:@@ -2774,6 +2777,7 @@ test('notice recovery keeps file links exact beside a matching document stem', acwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);const server = await bootCompositionRig(contentDir);try {await server.ready;@@ -2824,6 +2828,7 @@ test('a delivered alias retarget preserves both real link targets', async () =>cwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);const server = await bootCompositionRig(contentDir);try {await server.ready;@@ -2872,6 +2877,7 @@ test('a delivered general-file alias retains both link targets after recovery',cwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);const server = await bootCompositionRig(contentDir);try {await server.ready;@@ -2919,6 +2925,7 @@ test.each(['alias.csv', 'real.csv'])(cwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);const server = await bootCompositionRig(contentDir);try {await server.ready;@@ -3484,6 +3491,7 @@ async function bootInventoryServer() {cwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);const server = await bootCompositionRig(contentDir);await server.ready;return server;@@ -3821,6 +3829,7 @@ test('overlapping content and HEAD notices settle the owned Git branch and aliasconst git = (args: string[]) =>execFileSync('git', args, { cwd: contentDir, env: gitEnv, encoding: 'utf8' }).trim();git(['init', '--quiet', '--initial-branch=main']);+ configureTestGitRepository(contentDir);git(['config', 'user.email', '[email protected]']);git(['config', 'user.name', 'Notice Test']);const canonical = join(contentDir, 'canonical');@@ -4052,6 +4061,7 @@ test.each([cwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);const originalBytes = '# Original\n\nEarlier bytes.\n';const recreatedBytes =bytes === 'original' ? originalBytes : '# Recreated\n\nDifferent bytes now.\n';@@ -4187,6 +4197,7 @@ test.each(['before', 'during'] as const)(cwd: contentDir,env: gitEnv,});+ configureTestGitRepository(contentDir);const recreatedBytes = '# Recreated\n\nContent after the supplied deletes.\n';mkdirSync(join(contentDir, '.ok', 'templates'), { recursive: true });writeFileSync(join(contentDir, '.ok', 'templates', 'recreated.md'), recreatedBytes);@@ -8089,6 +8100,7 @@ test('a completed within-branch notice remains exact after its buffered target econst git = (args: string[]) =>execFileSync('git', args, { cwd: contentDir, env: gitEnv, encoding: 'utf8' }).trim();git(['init', '--quiet', '--initial-branch=main']);+ configureTestGitRepository(contentDir);git(['config', 'user.email', '[email protected]']);git(['config', 'user.name', 'Notice Test']);const a = writeDoc('a.csv', 'same,physical,bytes\n');diff --git a/packages/server/src/persistence-phantom-commit.test.ts b/packages/server/src/persistence-phantom-commit.test.tsindex b89818e0f..78c8d1170 100644--- a/packages/server/src/persistence-phantom-commit.test.ts+++ b/packages/server/src/persistence-phantom-commit.test.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { contributorCount, swapContributors } from './contributor-tracker.ts';import { createServer } from './server-factory.ts';@@ -48,6 +49,7 @@ async function setupFixture(): Promise<Fixture> {const contentDir = tmpDir;const git = simpleGit({ baseDir: tmpDir });await git.init();+ configureTestGitRepository(tmpDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');return {diff --git a/packages/server/src/persistence-phantom-doc-guard.test.ts b/packages/server/src/persistence-phantom-doc-guard.test.tsindex 2b043e267..d96182846 100644--- a/packages/server/src/persistence-phantom-doc-guard.test.ts+++ b/packages/server/src/persistence-phantom-doc-guard.test.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createServer } from './server-factory.ts';interface Fixture {@@ -17,6 +18,7 @@ async function setupFixture(): Promise<Fixture> {const contentDir = tmpDir;const git = simpleGit({ baseDir: tmpDir });await git.init();+ configureTestGitRepository(tmpDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');return {diff --git a/packages/server/src/persistence-tripwire-block.test.ts b/packages/server/src/persistence-tripwire-block.test.tsindex a376905b5..8f17b2f89 100644--- a/packages/server/src/persistence-tripwire-block.test.ts+++ b/packages/server/src/persistence-tripwire-block.test.ts@@ -5,6 +5,7 @@ import { updateYFragment } from '@tiptap/y-tiptap';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import type * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { expectStable } from './expect-stable.test-helper.ts';import { mdManager, schema } from './md-manager.ts';import { createServer } from './server-factory.ts';@@ -27,6 +28,7 @@ async function setupFixture(): Promise<Fixture> {const contentDir = tmpDir;const git = simpleGit({ baseDir: tmpDir });await git.init();+ configureTestGitRepository(tmpDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');return {diff --git a/packages/server/src/persistence-tripwire-paste.test.ts b/packages/server/src/persistence-tripwire-paste.test.tsindex a7f90a444..eee548c87 100644--- a/packages/server/src/persistence-tripwire-paste.test.ts+++ b/packages/server/src/persistence-tripwire-paste.test.ts@@ -15,6 +15,7 @@ import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiimport simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { composeAndWriteRawBody } from './bridge-intake.ts';import {DocumentDurabilityState,@@ -82,6 +83,7 @@ async function setupRig(prefix: string): Promise<Rig> {const tmpDir = await realpath(mkdtempSync(join(tmpdir(), prefix)));const git = simpleGit({ baseDir: tmpDir });await git.init();+ configureTestGitRepository(tmpDir);await git.raw('symbolic-ref', 'HEAD', 'refs/heads/main');await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');diff --git a/packages/server/src/persistence-ytext-truth.test.ts b/packages/server/src/persistence-ytext-truth.test.tsindex eba0717cc..82ca3ebb2 100644--- a/packages/server/src/persistence-ytext-truth.test.ts+++ b/packages/server/src/persistence-ytext-truth.test.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import { MarkdownManager, sharedExtensions } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { __resetQuiescenceForTests, __setQuiescentOverrideForTests } from './bridge-quiescence.ts';import { __resetBridgeWatchdogForTests } from './bridge-watchdog.ts';import { getMetrics, resetMetrics } from './metrics.ts';@@ -20,6 +21,7 @@ async function setupFixture(): Promise<Fixture> {const contentDir = tmpDir;const git = simpleGit({ baseDir: tmpDir });await git.init();+ configureTestGitRepository(tmpDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');return {diff --git a/packages/server/src/project-git.preflight.test.ts b/packages/server/src/project-git.preflight.test.tsindex 2e5162f69..e5b8246d1 100644--- a/packages/server/src/project-git.preflight.test.ts+++ b/packages/server/src/project-git.preflight.test.ts@@ -2,6 +2,7 @@ import { chmodSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {__resetResolveOnPathCacheForTests,__seedResolveOnPathCacheForTests,@@ -57,6 +58,7 @@ describe('ensureProjectGit — git-preflight at the project-setup boundary (#356await withBrokenBareGitOnly(async () => {outcome = await runEnsureProjectGit(project);});+ if (outcome === 'succeeded') configureTestGitRepository(project);} finally {rmSync(project, { recursive: true, force: true });}diff --git a/packages/server/src/project-git.test.ts b/packages/server/src/project-git.test.tsindex 2d57b0845..252571715 100644--- a/packages/server/src/project-git.test.ts+++ b/packages/server/src/project-git.test.ts@@ -5,6 +5,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import { promisify } from 'node:util';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {__resetResolveOnPathCacheForTests,__seedResolveOnPathCacheForTests,@@ -52,6 +53,7 @@ describe('ensureProjectGit', () => {expect(existsSync(resolve(projectRoot, '.git/ok/HEAD'))).toBe(true);const result = await ensureProjectGit(projectRoot);+ configureTestGitRepository(projectRoot);expect(result.didInit).toBe(true);expect(result.repaired).toBe(true);@@ -82,6 +84,7 @@ describe('ensureProjectGit', () => {const projectRoot = resolve(tmpDir, 'parent-repo');mkdirSync(projectRoot, { recursive: true });await execFileAsync('git', ['init', '--initial-branch=main', projectRoot]);+ configureTestGitRepository(projectRoot);const subFolder = resolve(projectRoot, 'nested/child');mkdirSync(subFolder, { recursive: true });@@ -97,6 +100,7 @@ describe('ensureProjectGit', () => {mkdirSync(projectRoot, { recursive: true });const result = await ensureProjectGit(projectRoot);+ configureTestGitRepository(projectRoot);expect(result.didInit).toBe(true);expect(existsSync(resolve(projectRoot, '.git/HEAD'))).toBe(true);@@ -117,6 +121,7 @@ describe('ensureProjectGit', () => {} finally {process.env.PATH = originalPath;}+ configureTestGitRepository(projectRoot);expect(existsSync(resolve(projectRoot, '.git/HEAD'))).toBe(true);});@@ -163,6 +168,7 @@ describe('ensureProjectGit — initial commit', () => {mkdirSync(projectRoot, { recursive: true });const result = await ensureProjectGit(projectRoot);+ configureTestGitRepository(projectRoot);expect(result.didInit).toBe(true);await expect(headResolves(projectRoot)).resolves.toBe(true);@@ -173,6 +179,7 @@ describe('ensureProjectGit — initial commit', () => {mkdirSync(projectRoot, { recursive: true });await ensureProjectGit(projectRoot);+ configureTestGitRepository(projectRoot);const worktreePath = resolve(projectRoot, '.ok/worktrees/wt-1');await expect(@@ -186,6 +193,7 @@ describe('ensureProjectGit — initial commit', () => {const projectRoot = resolve(tmpDir, 'stranded');mkdirSync(projectRoot, { recursive: true });await execFileAsync('git', ['init', '--initial-branch=main', projectRoot]);+ configureTestGitRepository(projectRoot);await expect(headResolves(projectRoot)).resolves.toBe(false);const result = await ensureProjectGit(projectRoot);@@ -198,6 +206,7 @@ describe('ensureProjectGit — initial commit', () => {const projectRoot = resolve(tmpDir, 'history-elsewhere');mkdirSync(projectRoot, { recursive: true });await execFileAsync('git', ['init', '--initial-branch=other', projectRoot]);+ configureTestGitRepository(projectRoot);await execFileAsync('git',['-c', 'user.name=T', '-c', '[email protected]', 'commit', '--allow-empty', '-m', 'existing'],@@ -219,6 +228,7 @@ describe('ensureProjectGit — initial commit', () => {mkdirSync(resolve(projectRoot, '.git/ok'), { recursive: true });const result = await ensureProjectGit(projectRoot);+ configureTestGitRepository(projectRoot);expect(result.repaired).toBe(true);await expect(headResolves(projectRoot)).resolves.toBe(true);@@ -244,6 +254,7 @@ describe('ensureProjectGit — initial commit', () => {).rejects.toBeDefined();await ensureProjectGit(projectRoot);+ configureTestGitRepository(projectRoot);await expect(headResolves(projectRoot)).resolves.toBe(true);const author = await execFileAsync('git', ['log', '-1', '--format=%an <%ae>'], {@@ -274,6 +285,7 @@ describe('ensureProjectGit — initial commit', () => {}try {await ensureProjectGit(projectRoot);+ configureTestGitRepository(projectRoot);const author = await execFileAsync('git', ['log', '-1', '--format=%an <%ae>'], {cwd: projectRoot,});diff --git a/packages/server/src/qa-gc-budget-isolation.test.ts b/packages/server/src/qa-gc-budget-isolation.test.tsindex a800ca9f3..048b450ad 100644--- a/packages/server/src/qa-gc-budget-isolation.test.ts+++ b/packages/server/src/qa-gc-budget-isolation.test.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {DEFAULT_CHECKPOINT_RETENTION,gcCheckpointRefs,@@ -25,6 +26,7 @@ beforeEach(async () => {mkdirSync(resolve(projectRoot, 'content/docs'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);diff --git a/packages/server/src/qa-sweep-lens.test.ts b/packages/server/src/qa-sweep-lens.test.tsindex 3a6effd16..845d16518 100644--- a/packages/server/src/qa-sweep-lens.test.ts+++ b/packages/server/src/qa-sweep-lens.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { type BridgeRaceRig, createBridgeRaceRig } from './bridge-race-rig.test-helper.ts';import type { LossCaptureEventInput } from './loss-capture.ts';import { getMetrics } from './metrics.ts';@@ -144,6 +145,7 @@ describe('QA-009: restore is NEVER automatic — checkpoint content stays out ofmkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(contentDir, 'qa009.md'), '# Seed\n');diff --git a/packages/server/src/rename-log.test.ts b/packages/server/src/rename-log.test.tsindex 37a94675a..65df0ac86 100644--- a/packages/server/src/rename-log.test.ts+++ b/packages/server/src/rename-log.test.ts@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { getLogger } from './logger.ts';import {appendRenameLogEntry,@@ -514,6 +515,7 @@ describe('rename-log read primitives (shadow-repo backed)', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -768,6 +770,7 @@ describe('batchCheckExistence timeout fallback (FR16 / D-T7)', () => {mkdirSync(projectRoot, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);@@ -1048,6 +1051,7 @@ describe('gcRenameLog (US-008 reachability + rebuild)', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -1521,6 +1525,7 @@ describe('buildSeeds — SeedsCache (Consider C2)', () => {mkdirSync(resolve(projectRoot, 'content'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);@@ -1561,6 +1566,7 @@ describe('gcRenameLog concurrency dedup (Finding 4)', () => {mkdirSync(resolve(projectRoot, 'content'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);diff --git a/packages/server/src/resolve-upstream-author.test.ts b/packages/server/src/resolve-upstream-author.test.tsindex 65ec60cda..1edb5f878 100644--- a/packages/server/src/resolve-upstream-author.test.ts+++ b/packages/server/src/resolve-upstream-author.test.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import simpleGit, { type SimpleGit } from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { resolveUpstreamChanges } from './server-factory.ts';describe('resolveUpstreamChanges', () => {@@ -27,6 +28,7 @@ describe('resolveUpstreamChanges', () => {dir = mkdtempSync(resolve(tmpdir(), 'ok-upstream-changes-'));git = simpleGit(dir);await git.init(['-b', 'main']);+ configureTestGitRepository(dir);await git.addConfig('user.name', 'Seed');await git.addConfig('user.email', '[email protected]');});diff --git a/packages/server/src/save-version.test.ts b/packages/server/src/save-version.test.tsindex a96c7a050..f475da8b7 100644--- a/packages/server/src/save-version.test.ts+++ b/packages/server/src/save-version.test.ts@@ -7,6 +7,7 @@ import { Hocuspocus } from '@hocuspocus/server';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { AgentSessionManager } from './agent-sessions.ts';import { createApiExtension } from './api-extension.test-helper.ts';import {@@ -117,6 +118,7 @@ describe('PRD-6716: save-version + rollback do not mutate parent git', () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# project\n');@@ -176,6 +178,7 @@ describe('PRD-6716: save-version + rollback do not mutate parent git', () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# project\n');@@ -239,6 +242,7 @@ describe('PRD-6716: save-version + rollback do not mutate parent git', () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');await git.add('.');@@ -323,6 +327,7 @@ describe('PRD-6972 FR6: Save Version unification', () => {mkdirSync(contentDir, { recursive: true });const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addConfig('user.name', 'Test');await git.addConfig('user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# project\n');diff --git a/packages/server/src/serialize-doc-vs-git-show-byte-equality.test.ts b/packages/server/src/serialize-doc-vs-git-show-byte-equality.test.tsindex cf49525eb..f6c9aebb3 100644--- a/packages/server/src/serialize-doc-vs-git-show-byte-equality.test.ts+++ b/packages/server/src/serialize-doc-vs-git-show-byte-equality.test.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import { prependFrontmatter, stripFrontmatter } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { __resetQuiescenceForTests } from './bridge-quiescence.ts';import { resetMetrics } from './metrics.ts';import { createServer } from './server-factory.ts';@@ -33,6 +34,7 @@ async function setupFixture(): Promise<Fixture> {const contentDir = tmpDir;const git = simpleGit({ baseDir: tmpDir });await git.init();+ configureTestGitRepository(tmpDir);await git.addConfig('user.name', 'A3 Test');await git.addConfig('user.email', '[email protected]');return {diff --git a/packages/server/src/serialize-doc-ytext.test.ts b/packages/server/src/serialize-doc-ytext.test.tsindex 4277bed86..12cd809af 100644--- a/packages/server/src/serialize-doc-ytext.test.ts+++ b/packages/server/src/serialize-doc-ytext.test.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { __resetQuiescenceForTests } from './bridge-quiescence.ts';import { resetMetrics } from './metrics.ts';import { createServer } from './server-factory.ts';@@ -21,6 +22,7 @@ async function setupFixture(): Promise<Fixture> {const contentDir = tmpDir;const git = simpleGit({ baseDir: tmpDir });await git.init();+ configureTestGitRepository(tmpDir);await git.addConfig('user.name', 'Test User');await git.addConfig('user.email', '[email protected]');return {diff --git a/packages/server/src/server-factory.conflict-authority.test.ts b/packages/server/src/server-factory.conflict-authority.test.tsindex 2f44bd712..ad0887296 100644--- a/packages/server/src/server-factory.conflict-authority.test.ts+++ b/packages/server/src/server-factory.conflict-authority.test.ts@@ -12,6 +12,7 @@ import {SyncConflictsSuccessSchema,} from '@inkeep/open-knowledge-core';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { bootServer } from './boot.ts';import { ConfigSchema } from './config/schema.ts';import * as headWatcher from './head-watcher.ts';@@ -171,6 +172,7 @@ async function bootWithHeldConflictedDoc(options?: {}> {const contentDir = tmpDir;await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);for (const [file, body] of Object.entries(options?.extraFiles ?? {})) {const abs = resolve(contentDir, file);diff --git a/packages/server/src/server-factory.conflict-ledger-lifecycle.test.ts b/packages/server/src/server-factory.conflict-ledger-lifecycle.test.tsindex d0d5c0956..12bac32af 100644--- a/packages/server/src/server-factory.conflict-ledger-lifecycle.test.ts+++ b/packages/server/src/server-factory.conflict-ledger-lifecycle.test.ts@@ -7,6 +7,7 @@ import { setTimeout as wait } from 'node:timers/promises';import { promisify } from 'node:util';import { OK_DIR } from '@inkeep/open-knowledge-core';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { bootServer } from './boot.ts';import { ConfigSchema } from './config/schema.ts';@@ -126,6 +127,7 @@ async function bootPlainProject(seed: (contentDir: string) => void): Promise<{}> {const contentDir = tmpDir;await execFileAsync('git', ['init', '--initial-branch=main', contentDir]);+ configureTestGitRepository(contentDir);seedOkScaffold(contentDir);seed(contentDir);const booted = await bootServer({@@ -171,6 +173,7 @@ describe('conflict ledger boot prune runs independently of the sync engine', ()const reconcileFile = 'notes/local.md';await execFileAsync('git', ['init', '--initial-branch=main', tmpDir]);+ configureTestGitRepository(tmpDir);seedOkScaffold(tmpDir);mkdirSync(resolve(tmpDir, 'notes'), { recursive: true });writeFileSync(resolve(tmpDir, DOC_FILE), 'line1\n', 'utf-8');diff --git a/packages/server/src/server-observers.producer-guard.test.ts b/packages/server/src/server-observers.producer-guard.test.tsindex 5e55ac9ef..b3ef89c4f 100644--- a/packages/server/src/server-observers.producer-guard.test.ts+++ b/packages/server/src/server-observers.producer-guard.test.ts@@ -8,6 +8,7 @@ import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiimport simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { getLogger } from './logger.ts';import { getMetrics } from './metrics.ts';import {@@ -214,6 +215,7 @@ describe('Producer guard (FR6) — packaged posture logs + checkpoints, never thmkdirSync(resolve(projectRoot, 'content'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);@@ -451,6 +453,7 @@ describe('Producer guard (FR6) — packaged posture logs + checkpoints, never thmkdirSync(resolve(brokenRoot, 'content'), { recursive: true });const brokenGit = simpleGit(brokenRoot);await brokenGit.init();+ configureTestGitRepository(brokenRoot);await brokenGit.raw('config', 'user.name', 'Test');await brokenGit.raw('config', 'user.email', '[email protected]');const brokenShadow = await initShadowRepo(brokenRoot);diff --git a/packages/server/src/server-shutdown-parcel-release.test.ts b/packages/server/src/server-shutdown-parcel-release.test.tsindex 488deb1cb..a4c79f66e 100644--- a/packages/server/src/server-shutdown-parcel-release.test.ts+++ b/packages/server/src/server-shutdown-parcel-release.test.ts@@ -3,6 +3,7 @@ import { mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, sep } from 'node:path';import { afterEach, beforeEach, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import type { BootedServer } from './boot.ts';import { bootCompositionRig } from './composition-rig.test-helper.ts';import { getWatcherDecisionRingSnapshot } from './file-watcher.ts';@@ -35,6 +36,7 @@ beforeEach(() => {GIT_CONFIG_NOSYSTEM: '1',},});+ configureTestGitRepository(root);});afterEach(async () => {diff --git a/packages/server/src/shadow-branch-gc.test.ts b/packages/server/src/shadow-branch-gc.test.tsindex a3433cdf0..876d6e8e3 100644--- a/packages/server/src/shadow-branch-gc.test.ts+++ b/packages/server/src/shadow-branch-gc.test.ts@@ -5,6 +5,7 @@ import { resolve } from 'node:path';import { parseCheckpoint } from '@inkeep/open-knowledge-core/shadow-repo-layout';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { gcShadowBranches } from './shadow-branch-gc';import { commitWip, initShadowRepo, shadowGit, type WriterIdentity } from './shadow-repo';@@ -31,6 +32,7 @@ describe('gcShadowBranches', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -53,6 +55,7 @@ describe('gcShadowBranches', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -99,6 +102,7 @@ describe('gcShadowBranches', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -134,6 +138,7 @@ describe('gcShadowBranches', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -158,6 +163,7 @@ describe('gcShadowBranches', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -207,6 +213,7 @@ describe('per-writer 30-day TTL GC on active branches (US-019, D54, FR-18)', ()const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');await git.add('.');@@ -253,6 +260,7 @@ describe('per-writer 30-day TTL GC on active branches (US-019, D54, FR-18)', ()const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');await git.add('.');@@ -286,6 +294,7 @@ describe('per-writer 30-day TTL GC on active branches (US-019, D54, FR-18)', ()writeFileSync(resolve(projectRoot, 'content', 'readme.md'), '# readme\n');const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');await git.add('.');diff --git a/packages/server/src/shadow-repo-stats.test.ts b/packages/server/src/shadow-repo-stats.test.tsindex 977a4a5a5..221a0bde6 100644--- a/packages/server/src/shadow-repo-stats.test.ts+++ b/packages/server/src/shadow-repo-stats.test.ts@@ -2,6 +2,7 @@ import { mkdirSync, writeFileSync } from 'node:fs';import { resolve } from 'node:path';import simpleGit from 'simple-git';import { afterAll, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createTempDirFactory } from '../../../test-support/temp-dir.test-helper.ts';import { initShadowRepo, type ShadowHandle, shadowGit } from './shadow-repo.ts';import { countStaleAgentWipRefs } from './shadow-repo-stats.ts';@@ -18,6 +19,7 @@ beforeEach(async () => {mkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(resolve(contentDir, 'intro.md'), '# Hello\n');diff --git a/packages/server/src/shadow-repo.test.ts b/packages/server/src/shadow-repo.test.tsindex 6d1509fa1..f5bdfe466 100644--- a/packages/server/src/shadow-repo.test.ts+++ b/packages/server/src/shadow-repo.test.ts@@ -15,6 +15,7 @@ import {} from '@inkeep/open-knowledge-core/shadow-repo-layout';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { applySkillWrite } from './content/skills-write.ts';import { getLogger } from './logger.ts';import { getMetrics, resetMetrics } from './metrics.ts';@@ -73,6 +74,7 @@ describe('initShadowRepo', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -96,6 +98,7 @@ describe('initShadowRepo', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -115,6 +118,7 @@ describe('initShadowRepo', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -131,12 +135,14 @@ describe('initShadowRepo', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');const legacyDir = resolve(projectRoot, '.git/openknowledge');mkdirSync(legacyDir, { recursive: true });await git.raw('init', '--bare', legacyDir);+ configureTestGitRepository(legacyDir);const sg = simpleGit({ timeout: { block: 30_000 } }).env({ GIT_DIR: legacyDir });await sg.raw('config', '--unset', 'core.bare');await sg.raw('config', 'core.worktree', projectRoot);@@ -156,6 +162,7 @@ describe('initShadowRepo', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -250,6 +257,7 @@ describe('buildWipTree persistent fan-out index', () => {mkdirSync(contentDir, { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);shadow = await initShadowRepo(projectRoot);});@@ -352,6 +360,7 @@ describe('commitWip', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -481,6 +490,7 @@ describe('commitUpstreamImport', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -561,6 +571,7 @@ describe('safetyCheckpoint', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -601,6 +612,7 @@ describe('parkBranch', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -743,6 +755,7 @@ describe('saveVersion', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -1001,6 +1014,7 @@ describe('saveInMemoryCheckpoint (bridge-correctness SPEC §6 R7a)', () => {mkdirSync(resolve(projectRoot, 'content/docs'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);@@ -1235,6 +1249,7 @@ describe('gcCheckpointRefs (bridge-correctness SPEC §6 R7 + review iteration 5)mkdirSync(resolve(projectRoot, 'content/docs'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);@@ -1688,6 +1703,7 @@ describe('checkpoint chain anchoring', () => {mkdirSync(resolve(projectRoot, 'content/docs'), { recursive: true });const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');shadow = await initShadowRepo(projectRoot);@@ -1858,6 +1874,7 @@ describe('sweepLegacyShadowRefs (US-018, D35, NFR-6)', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -1953,6 +1970,7 @@ describe('shadow repo excludes OpenKnowledge machine-local state', () => {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');diff --git a/packages/server/src/share/endpoint-real-git.test.ts b/packages/server/src/share/endpoint-real-git.test.tsindex c3896ce21..fb4bdb302 100644--- a/packages/server/src/share/endpoint-real-git.test.ts+++ b/packages/server/src/share/endpoint-real-git.test.ts@@ -3,8 +3,11 @@ import type { AddressInfo, Socket } from 'node:net';import { join } from 'node:path';import { decodeShareUrl } from '@inkeep/open-knowledge-core';import { afterEach, describe, expect, test } from 'vitest';+import {+ createGitTriangle,+ type GitTriangle,+} from '../../tests/support/git-fixture.test-helper.ts';import { bootEndpointServer, type EndpointRig } from './endpoint-http.test-helper.ts';-import { createGitTriangle, type GitTriangle } from './git-fixture.test-helper.ts';import { declareGitHubHosts, useIsolatedHome } from './git-host-declarations.test-helper.ts';import { computeShareTargetStatus } from './target-status.ts';diff --git a/packages/server/src/share/freshness.test.ts b/packages/server/src/share/freshness.test.tsindex 0be544aae..5571e59ab 100644--- a/packages/server/src/share/freshness.test.ts+++ b/packages/server/src/share/freshness.test.ts@@ -2,8 +2,11 @@ import { mkdtempSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, describe, expect, test } from 'vitest';+import {+ createGitTriangle,+ type GitTriangle,+} from '../../tests/support/git-fixture.test-helper.ts';import { computeShareFreshness } from './freshness.ts';-import { createGitTriangle, type GitTriangle } from './git-fixture.test-helper.ts';const triangles: GitTriangle[] = [];const scratchDirs: string[] = [];diff --git a/packages/server/src/share/git-fixture-maintenance.test.ts b/packages/server/src/share/git-fixture-maintenance.test.tsnew file mode 100644index 000000000..9a443bff7--- /dev/null+++ b/packages/server/src/share/git-fixture-maintenance.test.ts@@ -0,0 +1,57 @@+import { spawnSync } from 'node:child_process';+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { expect, test } from 'vitest';+import { z } from 'zod';+import { createGitTriangle } from '../../tests/support/git-fixture.test-helper.ts';++const traceEventSchema = z.object({+ event: z.string(),+ argv: z.array(z.string()).optional(),+});++test.each(['sender', 'receiver', 'origin'] as const)(+ '%s fixture finishes Git operations without automatic maintenance',+ (kind) => {+ const triangle = createGitTriangle();+ const traceDir = mkdtempSync(join(tmpdir(), 'ok-git-fixture-trace-'));+ try {+ const repository =+ kind === 'sender'+ ? triangle.senderDir+ : kind === 'origin'+ ? triangle.originDir+ : triangle.cloneReceiver();+ triangle.git(repository, ['config', 'maintenance.strategy', 'incremental']);+ triangle.git(repository, ['config', 'maintenance.loose-objects.auto', '-1']);+ const tracePath = join(traceDir, 'events.jsonl');+ const args =+ kind === 'origin'+ ? ['fetch', '--quiet', triangle.senderDir, triangle.branch]+ : ['commit', '--quiet', '--allow-empty', '-m', 'fixture operation'];+ const operation = spawnSync('git', args, {+ cwd: repository,+ env: { ...process.env, GIT_TRACE2_EVENT: tracePath },+ encoding: 'utf8',+ stdio: ['ignore', 'pipe', 'pipe', 'pipe'],+ });++ expect(operation.error).toBeUndefined();+ expect(operation.status, operation.stderr).toBe(0);+ const events = readFileSync(tracePath, 'utf8')+ .trim()+ .split('\n')+ .map((line) => traceEventSchema.parse(JSON.parse(line)));+ expect(events.some((event) => event.event === 'version')).toBe(true);+ expect(+ events+ .filter((event) => event.event === 'child_start' && event.argv?.[1] === 'maintenance')+ .map((event) => event.argv),+ ).toEqual([]);+ } finally {+ triangle.cleanup();+ rmSync(traceDir, { recursive: true, force: true });+ }+ },+);diff --git a/packages/server/src/share/git-fixture.test.ts b/packages/server/src/share/git-fixture.test.tsindex 72fca7222..16cd8f53d 100644--- a/packages/server/src/share/git-fixture.test.ts+++ b/packages/server/src/share/git-fixture.test.ts@@ -1,7 +1,10 @@import { spawnSync } from 'node:child_process';import { existsSync } from 'node:fs';import { afterEach, describe, expect, test } from 'vitest';-import { createGitTriangle, type GitTriangle } from './git-fixture.test-helper.ts';+import {+ createGitTriangle,+ type GitTriangle,+} from '../../tests/support/git-fixture.test-helper.ts';const triangles: GitTriangle[] = [];diff --git a/packages/server/src/share/github-account.test.ts b/packages/server/src/share/github-account.test.tsindex 32b0297bd..2dcbf1df5 100644--- a/packages/server/src/share/github-account.test.ts+++ b/packages/server/src/share/github-account.test.ts@@ -3,6 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';import {type CredentialUrlMatchReader,createCachedGitHubAccountResolver,@@ -40,6 +41,7 @@ function initRepo(name: string, config?: string): string {mkdirSync(root, { recursive: true });spawnSync('git', ['init', '-q'], { cwd: root, encoding: 'utf-8' });if (config) writeFileSync(join(root, '.git', 'config'), config, 'utf-8');+ configureTestGitRepository(root);return root;}diff --git a/packages/server/src/share/target-status.test.ts b/packages/server/src/share/target-status.test.tsindex 0551aba02..e4dea7787 100644--- a/packages/server/src/share/target-status.test.ts+++ b/packages/server/src/share/target-status.test.ts@@ -1,5 +1,8 @@import { afterEach, describe, expect, test } from 'vitest';-import { createGitTriangle, type GitTriangle } from './git-fixture.test-helper.ts';+import {+ createGitTriangle,+ type GitTriangle,+} from '../../tests/support/git-fixture.test-helper.ts';import { computeShareTargetStatus } from './target-status.ts';const triangles: GitTriangle[] = [];diff --git a/packages/server/src/shutdown-progress-refused.test.ts b/packages/server/src/shutdown-progress-refused.test.tsindex d6e1eb8a1..d21fd7d1e 100644--- a/packages/server/src/shutdown-progress-refused.test.ts+++ b/packages/server/src/shutdown-progress-refused.test.ts@@ -5,6 +5,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { expect, test, vi } from 'vitest';import * as Y from 'yjs';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { getLogger } from './logger.ts';import { ensureProjectGit } from './project-git.ts';import { createServer, type ServerInstance } from './server-factory.ts';@@ -80,6 +81,7 @@ async function withRefusedStoreShutdown(try {await mkdir(contentDir, { recursive: true });await ensureProjectGit(projectDir);+ configureTestGitRepository(projectDir);const shadowHandle = await initShadowRepo(projectDir);const refusedInitial = '# Refused shutdown doc\n\nPersisted paragraph.\n';writeFileSync(refusedPath, refusedInitial, 'utf-8');diff --git a/packages/server/src/shutdown-progress.test.ts b/packages/server/src/shutdown-progress.test.tsindex 733344dff..548201147 100644--- a/packages/server/src/shutdown-progress.test.ts+++ b/packages/server/src/shutdown-progress.test.ts@@ -3,6 +3,7 @@ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';import { tmpdir } from 'node:os';import { join } from 'node:path';import { expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { bootServer } from './boot.ts';import { ConfigSchema } from './config/schema.ts';import { getLogger } from './logger.ts';@@ -115,6 +116,7 @@ async function withLoadedDocuments(const cleanupErrors: unknown[] = [];try {await ensureProjectGit(projectDir);+ configureTestGitRepository(projectDir);await mkdir(join(projectDir, '.ok'), { recursive: true });await writeFile(join(projectDir, '.ok', 'config.yml'), '');for (const name of names) await writeFile(join(projectDir, `${name}.md`), `# ${name}\n`);diff --git a/packages/server/src/skill-source-cache.test.ts b/packages/server/src/skill-source-cache.test.tsindex 0f2aae904..5a74d51d4 100644--- a/packages/server/src/skill-source-cache.test.ts+++ b/packages/server/src/skill-source-cache.test.ts@@ -8,6 +8,7 @@ import {type SourceSpec,} from '@inkeep/open-knowledge-core/skills-catalog';import { afterEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { clearSourceCache, fetchCachedSource } from './skill-source-cache.ts';interface SkillFixture {@@ -38,6 +39,7 @@ function makeGitRepo(skills: SkillFixture[]): string {}const git = (args: string[]) => execFileSync('git', ['-C', repo, ...args], { stdio: 'pipe' });git(['init', '-q']);+ configureTestGitRepository(repo);git(['config', 'user.email', '[email protected]']);git(['config', 'user.name', 'Test']);git(['config', 'commit.gpgsign', 'false']);@@ -73,6 +75,7 @@ describe('fetchCachedSource', () => {{ dir: 'beta', name: 'beta', description: 'B' },]);const first = await fetchCachedSource(gitSpec(src));+ configureTestGitRepository(first.dir);const second = await fetchCachedSource(gitSpec(src));expect(second.dir).toBe(first.dir);expect(skillNames(first.dir)).toEqual(['alpha', 'beta']);@@ -84,6 +87,7 @@ describe('fetchCachedSource', () => {fetchCachedSource(gitSpec(src)),fetchCachedSource(gitSpec(src)),]);+ for (const dir of new Set([a.dir, b.dir])) configureTestGitRepository(dir);expect(b.dir).toBe(a.dir);});@@ -91,7 +95,9 @@ describe('fetchCachedSource', () => {const one = repo([{ dir: 'one', name: 'skill-one', description: 'One' }]);const two = repo([{ dir: 'two', name: 'skill-two', description: 'Two' }]);const a = await fetchCachedSource(gitSpec(one));+ configureTestGitRepository(a.dir);const b = await fetchCachedSource(gitSpec(two));+ configureTestGitRepository(b.dir);expect(a.dir).not.toBe(b.dir);expect(skillNames(a.dir)).toEqual(['skill-one']);expect(skillNames(b.dir)).toEqual(['skill-two']);@@ -100,6 +106,7 @@ describe('fetchCachedSource', () => {test('the clone path resolves a real commit sha and clearing removes the clone', async () => {const src = repo([{ dir: 'alpha', name: 'alpha', description: 'A' }]);const fetched = await fetchCachedSource(gitSpec(src));+ configureTestGitRepository(fetched.dir);expect(fetched.ref).toMatch(/^[0-9a-f]{40}$/);const clonedDir = fetched.dir;expect(existsSync(clonedDir)).toBe(true);@@ -112,6 +119,7 @@ describe('fetchCachedSource', () => {test('an entry past the TTL is swept, its clone removed, and the next call re-clones', async () => {const src = repo([{ dir: 'alpha', name: 'alpha', description: 'A' }]);const first = await fetchCachedSource(gitSpec(src));+ configureTestGitRepository(first.dir);const clonedDir = first.dir;expect(existsSync(clonedDir)).toBe(true);@@ -120,6 +128,7 @@ describe('fetchCachedSource', () => {try {vi.setSystemTime(Date.now() + 31_000);second = await fetchCachedSource(gitSpec(src));+ configureTestGitRepository(second.dir);} finally {vi.useRealTimers();}@@ -144,6 +153,7 @@ describe('fetchCachedSource', () => {await expect(fetchCachedSource(gitSpec(missing))).rejects.toThrow();const src = repo([{ dir: 'alpha', name: 'alpha', description: 'A' }]);const ok = await fetchCachedSource(gitSpec(src));+ configureTestGitRepository(ok.dir);expect(skillNames(ok.dir)).toEqual(['alpha']);});});diff --git a/packages/server/src/summary-e2e.test.ts b/packages/server/src/summary-e2e.test.tsindex f3708475c..b6d2a0778 100644--- a/packages/server/src/summary-e2e.test.ts+++ b/packages/server/src/summary-e2e.test.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import {formatContributorsFrom,recordContributor,@@ -17,6 +18,7 @@ async function bootstrap(): Promise<string> {projectDir = mkdtempSync(join(tmpdir(), 'ok-summary-e2e-'));const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');const contentDir = resolve(projectDir, 'content');diff --git a/packages/server/src/sync-engine.incoming-symlinks.test.ts b/packages/server/src/sync-engine.incoming-symlinks.test.tsindex cd5c51974..103642c70 100644--- a/packages/server/src/sync-engine.incoming-symlinks.test.ts+++ b/packages/server/src/sync-engine.incoming-symlinks.test.ts@@ -15,6 +15,7 @@ import { join } from 'node:path';import { LOCAL_DIR } from '@inkeep/open-knowledge-core';import simpleGit, { type SimpleGit } from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createTestConflictAuthority } from './conflict-authority.test-helper.ts';import { classifyGitError } from './error-classification.ts';import { runCheckoutFlow } from './git-checkout.ts';@@ -44,11 +45,13 @@ beforeEach(async () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');mkdirSync(sisterDir, { recursive: true });sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');mkdirSync(join(sisterDir, 'notes'), { recursive: true });@@ -59,6 +62,7 @@ beforeEach(async () => {await sister.push('origin', 'main');await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(join(projectDir, '.ok', LOCAL_DIR), { recursive: true });writeFileSync(join(projectDir, '.ok', LOCAL_DIR, 'principal.json'), '{"secret":1}\n', 'utf-8');project = simpleGit(projectDir);diff --git a/packages/server/src/sync-engine.index-heal.test.ts b/packages/server/src/sync-engine.index-heal.test.tsindex 0e8eff6be..4e62a8049 100644--- a/packages/server/src/sync-engine.index-heal.test.ts+++ b/packages/server/src/sync-engine.index-heal.test.ts@@ -13,6 +13,7 @@ import { join } from 'node:path';import { LOCAL_DIR, type SyncMode } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createTestConflictAuthority } from './conflict-authority.test-helper.ts';import { getLogger } from './logger.ts';import { SyncEngine } from './sync-engine.ts';@@ -81,10 +82,12 @@ async function projectWithBareOrigin() {const bare = join(tmpDir, 'bare.git');mkdirSync(bare, { recursive: true });await simpleGit(bare).init(true);+ configureTestGitRepository(bare);await simpleGit(bare).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);ignoreOkDir();await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -114,6 +117,7 @@ function makeEngine(async function advanceOriginFromSisterClone(bare: string): Promise<void> {const sister = join(tmpDir, 'sister');await simpleGit().clone(bare, sister);+ configureTestGitRepository(sister);const sg = simpleGit(sister);await sg.raw('config', 'user.name', 'Sister');await sg.raw('config', 'user.email', '[email protected]');diff --git a/packages/server/src/sync-engine.stamp-persistence.test.ts b/packages/server/src/sync-engine.stamp-persistence.test.tsindex 846d93417..9c32bd825 100644--- a/packages/server/src/sync-engine.stamp-persistence.test.ts+++ b/packages/server/src/sync-engine.stamp-persistence.test.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import { LOCAL_DIR, type SyncMode } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createTestConflictAuthority } from './conflict-authority.test-helper.ts';import { getLogger } from './logger.ts';import { SyncEngine } from './sync-engine.ts';@@ -54,10 +55,12 @@ async function projectWithBareOrigin() {const bare = join(tmpDir, 'bare.git');mkdirSync(bare, { recursive: true });await simpleGit(bare).init(true);+ configureTestGitRepository(bare);await simpleGit(bare).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'doc.md'), 'v1\n', 'utf-8');diff --git a/packages/server/src/sync-engine.state-persist.test.ts b/packages/server/src/sync-engine.state-persist.test.tsindex 6295c01b2..7ec1c100b 100644--- a/packages/server/src/sync-engine.state-persist.test.ts+++ b/packages/server/src/sync-engine.state-persist.test.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import { LOCAL_DIR } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createTestConflictAuthority } from './conflict-authority.test-helper.ts';import { SyncEngine } from './sync-engine.ts';@@ -48,6 +49,7 @@ beforeEach(async () => {mkdirSync(okDir, { recursive: true });const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');});diff --git a/packages/server/src/sync-engine.test.ts b/packages/server/src/sync-engine.test.tsindex ca716c200..b66f00ce4 100644--- a/packages/server/src/sync-engine.test.ts+++ b/packages/server/src/sync-engine.test.ts@@ -17,6 +17,7 @@ import { promisify } from 'node:util';import { LOCAL_DIR, type SyncMode, SyncStatusSchema } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, onTestFinished, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { type Conflict, ConflictAuthority } from './conflict-authority.ts';import { createContentFilter } from './content-filter.ts';import { classifyGitError } from './error-classification.ts';@@ -137,6 +138,7 @@ function makeEngine(async function initGitWithOrigin(originUrl = 'https://github.com/inkeep/open-knowledge.git') {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), 'seed\n', 'utf-8');@@ -342,6 +344,7 @@ describe('SyncEngine state persistence round-trip', () => {async function setupRealMergeConflict(files: string[]): Promise<void> {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');for (const f of files) {@@ -365,6 +368,7 @@ describe('SyncEngine state persistence round-trip', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);}@@ -408,6 +412,7 @@ describe('SyncEngine state persistence round-trip', () => {test('clears stale conflicts.json when MERGE_HEAD is gone (user resolved externally)', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -416,6 +421,7 @@ describe('SyncEngine state persistence round-trip', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);writeFileSync(@@ -624,12 +630,14 @@ describe('SyncEngine ConflictStore admission (content-only)', () => {mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const sisterDir = join(tmpDir, 'sister');mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, '.mcp.json'), '{"a":1}\n', 'utf-8');@@ -642,6 +650,7 @@ describe('SyncEngine ConflictStore admission (content-only)', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);await project.raw('config', 'user.name', 'Project');@@ -785,6 +794,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {mkdirSync(sisterDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const v1 = JSON.stringify({@@ -796,6 +806,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {const v2 = v1.replace('# ok-mcp-v1', '# ok-mcp-v2');const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, '.mcp.json'), `${v1}\n`, 'utf-8');@@ -806,6 +817,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });appendFileSync(join(projectDir, '.git', 'info', 'exclude'), '\n.ok/\n', 'utf-8');@@ -845,6 +857,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {mkdirSync(sisterDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const config = (marker: string, theme: string) =>@@ -860,6 +873,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {})}\n`;const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, '.mcp.json'), config('# ok-mcp-v1', 'base'), 'utf8');@@ -870,6 +884,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });writeFileSync(join(sisterDir, '.mcp.json'), config('# ok-mcp-v2', 'incoming'), 'utf8');@@ -907,6 +922,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {test('full sync persists a newer winner in an entry-only generated commit', async () => {const project = simpleGit(projectDir);await project.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await project.raw('config', 'user.name', 'Project');await project.raw('config', 'user.email', '[email protected]');const entry = (marker: string) => ({@@ -970,6 +986,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {mkdirSync(sisterDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const config = (marker: string) =>@@ -984,6 +1001,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {})}\n`;const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, '.gitignore'), '/.ok/*\n', 'utf8');@@ -996,6 +1014,7 @@ describe('SyncEngine tracked MCP overlap preparation', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });await simpleGit(projectDir).raw(['config', 'user.name', '']);await simpleGit(projectDir).raw(['config', 'user.email', '']);@@ -1051,11 +1070,13 @@ describe('SyncEngine delete/modify dirty content conflicts', () => {mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);const sisterDir = join(tmpDir, 'sister');mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'foo.md'), 'base\n', 'utf-8');@@ -1067,6 +1088,7 @@ describe('SyncEngine delete/modify dirty content conflicts', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir, ['--branch', 'main']);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);@@ -1086,11 +1108,13 @@ describe('SyncEngine delete/modify dirty content conflicts', () => {mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);const sisterDir = join(tmpDir, 'sister');mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'foo.md'), 'base\n', 'utf-8');@@ -1102,6 +1126,7 @@ describe('SyncEngine delete/modify dirty content conflicts', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir, ['--branch', 'main']);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);@@ -1198,11 +1223,13 @@ describe('SyncEngine non-ASCII filename conflicts', () => {mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);const sisterDir = join(tmpDir, 'sister');mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, fileName), 'base\n', 'utf-8');@@ -1214,6 +1241,7 @@ describe('SyncEngine non-ASCII filename conflicts', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir, ['--branch', 'main']);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);@@ -1277,10 +1305,12 @@ describe('SyncEngine push gating — scheduled vs explicit', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# seed\n');@@ -1349,10 +1379,12 @@ describe('SyncEngine lastRunUtc — "Updated N ago"', () => {const bare = join(tmpDir, 'bare.git');mkdirSync(bare, { recursive: true });await simpleGit(bare).init(true);+ configureTestGitRepository(bare);await simpleGit(bare).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'doc.md'), 'v1\n');@@ -1421,6 +1453,7 @@ describe('SyncEngine lastRunUtc — "Updated N ago"', () => {test('a failed op does not stamp a run', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'doc.md'), 'v1\n');@@ -1444,10 +1477,12 @@ describe('SyncEngine unified pull — B1 in every mode', () => {const bare = join(tmpDir, 'bare.git');mkdirSync(bare, { recursive: true });await simpleGit(bare).init(true);+ configureTestGitRepository(bare);await simpleGit(bare).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(@@ -1461,6 +1496,7 @@ describe('SyncEngine unified pull — B1 in every mode', () => {const sisterDir = join(tmpDir, 'sister');await simpleGit(tmpDir).clone(bare, sisterDir);+ configureTestGitRepository(sisterDir);const sister = simpleGit(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');@@ -1647,10 +1683,12 @@ describe('SyncEngine fetchOnly() — the read-only op', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'doc.md'), 'v1\n');@@ -1664,6 +1702,7 @@ describe('SyncEngine fetchOnly() — the read-only op', () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.clone(bareDir, sisterDir);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'doc.md'), 'v1\nv2\n');@@ -1688,6 +1727,7 @@ describe('SyncEngine fetchOnly() — the read-only op', () => {test('a failed fetch stays quiet — no error surfaced, no pause', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'doc.md'), 'v1\n');@@ -1729,6 +1769,7 @@ describe('SyncEngine refreshRemote()', () => {test('is a no-op when hasRemote is already true', async () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addRemote('origin', 'https://example.invalid/repo.git');const states: SyncState[] = [];@@ -1746,6 +1787,7 @@ describe('SyncEngine refreshRemote()', () => {test('detects a newly-added remote and transitions dormant → disabled (syncEnabled=false)', async () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);const states: SyncState[] = [];const engine = makeEngine({ syncEnabled: false, onStateChange: (s) => states.push(s) });@@ -1765,6 +1807,7 @@ describe('SyncEngine refreshRemote()', () => {test('detects a newly-added remote and transitions dormant → idle (syncEnabled=true)', async () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);const states: SyncState[] = [];const engine = makeEngine({ syncEnabled: true, onStateChange: (s) => states.push(s) });@@ -1786,6 +1829,7 @@ describe('SyncEngine refreshRemote()', () => {test('stays dormant when no remote was added since boot', async () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);const engine = makeEngine({ syncEnabled: false });await engine.start();@@ -1809,6 +1853,7 @@ describe('SyncEngine setEnabled() — unconditional remote re-probe', () => {test('setEnabled(true) demotes to dormant when remote was removed since boot', async () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);await git.addRemote('origin', 'https://example.invalid/repo.git');const engine = makeEngine({ syncEnabled: false });@@ -1827,6 +1872,7 @@ describe('SyncEngine setEnabled() — unconditional remote re-probe', () => {test('setEnabled(true) transitions dormant → idle when remote was added since boot', async () => {const git = simpleGit(projectDir);await git.init();+ configureTestGitRepository(projectDir);const engine = makeEngine({ syncEnabled: false });await engine.start();@@ -2040,11 +2086,13 @@ describe('SyncEngine unborn-HEAD guard', () => {async function initRepoWithOrigin(withCommit: boolean) {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');const bareDir = join(tmpDir, 'unborn-bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');await git.addRemote('origin', bareDir);if (withCommit) {@@ -2730,6 +2778,7 @@ describe('SyncEngine push cycle pushes existing commits when local is ahead of otest('pushes existing HEAD when local is ahead of origin and tree is clean', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -2739,6 +2788,7 @@ describe('SyncEngine push cycle pushes existing commits when local is ahead of oconst bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);@@ -2766,6 +2816,7 @@ describe('SyncEngine push cycle pushes existing commits when local is ahead of otest('records lastSyncUtc when HEAD already matches origin and tree is clean', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -2775,6 +2826,7 @@ describe('SyncEngine push cycle pushes existing commits when local is ahead of oconst bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);@@ -2799,6 +2851,7 @@ describe('SyncEngine push cycle with non-ASCII filenames', () => {test('commits and pushes the deletion of a file with a non-ASCII name', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -2809,6 +2862,7 @@ describe('SyncEngine push cycle with non-ASCII filenames', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);@@ -2847,6 +2901,7 @@ describe('SyncEngine push cycle vs gitignored content (precedent #55 at the stagasync function initRepoWithBareRemote() {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -2856,6 +2911,7 @@ describe('SyncEngine push cycle vs gitignored content (precedent #55 at the stagconst bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);return git;@@ -2973,6 +3029,7 @@ describe('SyncEngine push cycle stages shareable .ok artifacts (sync scope)', ()async function initSharedRepoWithBareRemote() {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('symbolic-ref', 'HEAD', 'refs/heads/main');await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');@@ -2984,6 +3041,7 @@ describe('SyncEngine push cycle stages shareable .ok artifacts (sync scope)', ()mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);@@ -3003,6 +3061,7 @@ describe('SyncEngine push cycle stages shareable .ok artifacts (sync scope)', ()async function cloneAsTeammate(bareDir: string) {const sisterDir = join(tmpDir, 'sister');await simpleGit(tmpDir).clone(bareDir, sisterDir);+ configureTestGitRepository(sisterDir);const sister = simpleGit(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');@@ -3909,6 +3968,7 @@ describe('SyncEngine per-operation error isolation', () => {test('a successful fetch does not clear a standing push error', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -3918,6 +3978,7 @@ describe('SyncEngine per-operation error isolation', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);@@ -3944,6 +4005,7 @@ describe('SyncEngine per-operation error isolation', () => {test('a successful push does not clear a standing pull error', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -3953,6 +4015,7 @@ describe('SyncEngine per-operation error isolation', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);await git.raw('config', 'remote.origin.url', join(tmpDir, 'nonexistent-bare.git'));@@ -4737,6 +4800,7 @@ describe('SyncEngine auth-error recovery', () => {test('a manual trigger clears the identity-ambiguous not-found park', async () => {await simpleGit(projectDir).init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);const engine = makeEngine({ syncEnabled: true });const internal = engine as unknown as InternalState;internal.state = 'auth-error';@@ -4769,6 +4833,7 @@ describe('SyncEngine auth-error recovery', () => {test('a pull-side not-found park clears on manual trigger too', async () => {await simpleGit(projectDir).init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);const engine = makeEngine({ syncEnabled: true });const internal = engine as unknown as InternalState;internal.state = 'auth-error';@@ -4787,6 +4852,7 @@ describe('SyncEngine auth-error recovery', () => {test('un-parking via trigger(push) revives the pull loop', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -4795,6 +4861,7 @@ describe('SyncEngine auth-error recovery', () => {const bareDir = join(tmpDir, 'unpark-bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);@@ -4894,6 +4961,7 @@ describe('SyncEngine gh-token credential relay', () => {test('threads the resolved gh token through git handles during a real push cycle', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# Test\n');@@ -4903,6 +4971,7 @@ describe('SyncEngine gh-token credential relay', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await git.addRemote('origin', bareDir);await git.push(['--set-upstream', 'origin', 'main']);@@ -5262,6 +5331,7 @@ describe('SyncEngine pull-only mode', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');return bareDir;}@@ -5273,6 +5343,7 @@ describe('SyncEngine pull-only mode', () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'doc.md'), 'v1\n', 'utf-8');@@ -5283,6 +5354,7 @@ describe('SyncEngine pull-only mode', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });writeFileSync(join(sisterDir, 'doc.md'), 'v1\nv2\n', 'utf-8');@@ -5315,6 +5387,7 @@ describe('SyncEngine pull-only mode', () => {test('never pushes local commits on its own, but honors an explicit push', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'README.md'), '# seed\n');@@ -5396,6 +5469,7 @@ describe('SyncEngine pull-only B1 fast-forward cycle', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');return bareDir;}@@ -5409,6 +5483,7 @@ describe('SyncEngine pull-only B1 fast-forward cycle', () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');for (const [f, c] of Object.entries(opts.seed)) writeFileSync(join(sisterDir, f), c, 'utf-8');@@ -5419,6 +5494,7 @@ describe('SyncEngine pull-only B1 fast-forward cycle', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });for (const [f, c] of Object.entries(opts.advance)) {@@ -5733,6 +5809,7 @@ describe('SyncEngine pull-only B1 fast-forward cycle', () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'a.md'), 'A1\n', 'utf-8');@@ -5743,6 +5820,7 @@ describe('SyncEngine pull-only B1 fast-forward cycle', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });writeFileSync(join(projectDir, 'a.md'), 'A1\nLOCAL\n', 'utf-8');@@ -5774,6 +5852,7 @@ describe('SyncEngine pull-only B1 fast-forward cycle', () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'a.md'), 'A1\n', 'utf-8');@@ -5786,6 +5865,7 @@ describe('SyncEngine pull-only B1 fast-forward cycle', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const escapeDir = join(tmpDir, 'escape-dir');@@ -6263,6 +6343,7 @@ describe('SyncEngine pull-only mode transitions', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');return bareDir;}@@ -6278,6 +6359,7 @@ describe('SyncEngine pull-only mode transitions', () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');for (const [f, c] of Object.entries(seed)) writeFileSync(join(sisterDir, f), c, 'utf-8');@@ -6289,6 +6371,7 @@ describe('SyncEngine pull-only mode transitions', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);await project.raw('config', 'user.name', 'Follower');@@ -6527,6 +6610,7 @@ describe('classifyFastForwardRefusal (pinned against real git)', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');return bareDir;}@@ -6537,6 +6621,7 @@ describe('classifyFastForwardRefusal (pinned against real git)', () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'a.md'), 'l1\nl2\n', 'utf-8');@@ -6546,6 +6631,7 @@ describe('classifyFastForwardRefusal (pinned against real git)', () => {await sister.push('origin', 'main');rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });writeFileSync(join(sisterDir, 'a.md'), advance, 'utf-8');await sister.add('.');@@ -6581,6 +6667,7 @@ describe("SyncEngine one-shot pull (op 'pull')", () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');return bareDir;}@@ -6594,6 +6681,7 @@ describe("SyncEngine one-shot pull (op 'pull')", () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');for (const [f, c] of Object.entries(opts.seed)) writeFileSync(join(sisterDir, f), c, 'utf-8');@@ -6604,6 +6692,7 @@ describe("SyncEngine one-shot pull (op 'pull')", () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });if (opts.advance) {@@ -6768,6 +6857,7 @@ describe("SyncEngine one-shot pull (op 'pull')", () => {test('refuses when there is no remote', async () => {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Solo');await git.raw('config', 'user.email', '[email protected]');writeFileSync(join(projectDir, 'doc.md'), 'v1\n', 'utf-8');@@ -6790,6 +6880,7 @@ describe('SyncEngine telemetry', () => {const bareDir = join(tmpDir, 'bare.git');mkdirSync(bareDir, { recursive: true });await simpleGit(bareDir).init(true);+ configureTestGitRepository(bareDir);await simpleGit(bareDir).raw('symbolic-ref', 'HEAD', 'refs/heads/main');return bareDir;}@@ -6803,6 +6894,7 @@ describe('SyncEngine telemetry', () => {mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');for (const [f, c] of Object.entries(opts.seed)) writeFileSync(join(sisterDir, f), c, 'utf-8');@@ -6813,6 +6905,7 @@ describe('SyncEngine telemetry', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });if (opts.advance) {@@ -6953,12 +7046,14 @@ describe('SyncEngine blocking-change resolution', () => {mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const sisterDir = join(tmpDir, 'sister');mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'settings.json'), '{"a":1}\n', 'utf-8');@@ -6971,6 +7066,7 @@ describe('SyncEngine blocking-change resolution', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);await project.raw('config', 'user.name', 'Project');@@ -7163,12 +7259,14 @@ describe('SyncEngine split-leg backoff, end to end', () => {mkdirSync(bareDir, { recursive: true });const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw('symbolic-ref', 'HEAD', 'refs/heads/main');const sisterDir = join(tmpDir, 'sister');mkdirSync(sisterDir, { recursive: true });const sister = simpleGit(sisterDir);await sister.init(['--initial-branch=main']);+ configureTestGitRepository(sisterDir);await sister.raw('config', 'user.name', 'Sister');await sister.raw('config', 'user.email', '[email protected]');writeFileSync(join(sisterDir, 'foo.md'), 'base\n', 'utf-8');@@ -7179,6 +7277,7 @@ describe('SyncEngine split-leg backoff, end to end', () => {rmSync(projectDir, { recursive: true, force: true });await simpleGit(tmpDir).clone(bareDir, projectDir);+ configureTestGitRepository(projectDir);mkdirSync(okDir, { recursive: true });const project = simpleGit(projectDir);await project.raw('config', 'user.name', 'Project');@@ -7323,6 +7422,7 @@ describe('SyncEngine exclusive merge ownership', () => {mkdirSync(bareDir);const bare = simpleGit(bareDir);await bare.init(true);+ configureTestGitRepository(bareDir);await bare.raw(['symbolic-ref', 'HEAD', 'refs/heads/main']);const git = await initGitWithOrigin(bareDir);writeFileSync(join(projectDir, '.git', 'info', 'exclude'), '.ok/\n');@@ -7345,6 +7445,7 @@ describe('SyncEngine exclusive merge ownership', () => {async function diverge(bareDir: string) {const sisterDir = join(tmpDir, 'exclusive-sister');await simpleGit(tmpDir).clone(bareDir, sisterDir);+ configureTestGitRepository(sisterDir);const sister = simpleGit(sisterDir);await sister.raw(['config', 'user.name', 'Sister']);await sister.raw(['config', 'user.email', '[email protected]']);diff --git a/packages/server/src/sync-engine.unborn-head.test.ts b/packages/server/src/sync-engine.unborn-head.test.tsindex a8a429570..15325ea80 100644--- a/packages/server/src/sync-engine.unborn-head.test.ts+++ b/packages/server/src/sync-engine.unborn-head.test.ts@@ -4,6 +4,7 @@ import { join } from 'node:path';import { LOCAL_DIR, type SyncMode } from '@inkeep/open-knowledge-core';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { createTestConflictAuthority } from './conflict-authority.test-helper.ts';import { getLogger } from './logger.ts';import { SyncEngine } from './sync-engine.ts';@@ -63,6 +64,7 @@ function statePath(): string {async function emptyProject() {const git = simpleGit(projectDir);await git.init(['--initial-branch=main']);+ configureTestGitRepository(projectDir);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');return git;@@ -72,6 +74,7 @@ async function emptyProjectWithBareOrigin() {const bare = join(tmpDir, 'bare.git');mkdirSync(bare, { recursive: true });await simpleGit(bare).init(true);+ configureTestGitRepository(bare);await simpleGit(bare).raw('symbolic-ref', 'HEAD', 'refs/heads/main');const git = await emptyProject();diff --git a/packages/server/src/timeline-query.test.ts b/packages/server/src/timeline-query.test.tsindex 3bbd78edc..818b41383 100644--- a/packages/server/src/timeline-query.test.ts+++ b/packages/server/src/timeline-query.test.ts@@ -7,6 +7,7 @@ import { templateContentDocName } from '@inkeep/open-knowledge-core';import { formatOkActor, type OkActorEntry } from '@inkeep/open-knowledge-core/shadow-repo-layout';import simpleGit from 'simple-git';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { getLogger } from './logger.ts';import {appendRenameLogEntry,@@ -110,6 +111,7 @@ async function setup() {const git = simpleGit(projectRoot);await git.init();+ configureTestGitRepository(projectRoot);await git.raw('config', 'user.name', 'Test');await git.raw('config', 'user.email', '[email protected]');diff --git a/packages/server/src/upstream-attribution.integration.test.ts b/packages/server/src/upstream-attribution.integration.test.tsindex a6728fd90..0d6ed47ef 100644--- a/packages/server/src/upstream-attribution.integration.test.ts+++ b/packages/server/src/upstream-attribution.integration.test.ts@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os';import { resolve } from 'node:path';import simpleGit, { type SimpleGit } from 'simple-git';import { afterEach, beforeEach, expect, test } from 'vitest';+import { configureTestGitRepository } from '../../../test-support/configure-git-fixture.test-helper.ts';import { __resetContributorsForTests as resetContributorsForTest } from './contributor-tracker.ts';import { createServer, type ServerInstance } from './server-factory.ts';import { initShadowRepo, type ShadowHandle, shadowGit } from './shadow-repo.ts';@@ -31,6 +32,7 @@ beforeEach(async () => {dir = mkdtempSync(resolve(tmpdir(), 'ok-upstream-attr-int-'));git = simpleGit(dir);await git.init(['-b', 'main']);+ configureTestGitRepository(dir);await git.addConfig('user.name', 'Seed');await git.addConfig('user.email', '[email protected]');await commitAs('Seed', '[email protected]', 'bugs.md', '# Bugs\n\ninitial\n');diff --git a/packages/server/src/share/git-fixture.test-helper.ts b/packages/server/tests/support/git-fixture.test-helper.tssimilarity index 96%rename from packages/server/src/share/git-fixture.test-helper.tsrename to packages/server/tests/support/git-fixture.test-helper.tsindex 8cadd3c88..8d412de05 100644--- a/packages/server/src/share/git-fixture.test-helper.ts+++ b/packages/server/tests/support/git-fixture.test-helper.ts@@ -2,6 +2,7 @@ import { execFileSync } from 'node:child_process';import { mkdirSync, mkdtempSync, renameSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { dirname, join, relative } from 'node:path';+import { configureTestGitRepository } from '../../../../test-support/configure-git-fixture.test-helper.ts';export interface GitTriangle {readonly senderDir: string;@@ -56,7 +57,9 @@ export function createGitTriangle(opts: { branch?: string } = {}): GitTriangle {};git(originDir, ['init', '--bare', '-b', branch]);+ configureTestGitRepository(originDir);git(senderDir, ['init', '-b', branch]);+ configureTestGitRepository(senderDir);configure(senderDir);writeFile(senderDir, '.ok/config.yml', '');writeFile(senderDir, 'README.md', '# base\n');@@ -147,6 +150,7 @@ export function createGitTriangle(opts: { branch?: string } = {}): GitTriangle {if (receiverDir) return receiverDir;const dir = mkdtempSync(join(tmpdir(), 'ok-share-receiver-'));git(dir, ['clone', originDir, '.']);+ configureTestGitRepository(dir);configure(dir);receiverDir = dir;return dir;diff --git a/scripts/check-i18n-new-string-translations.test.mjs b/scripts/check-i18n-new-string-translations.test.mjsindex 42a8d0efa..19e17a718 100644--- a/scripts/check-i18n-new-string-translations.test.mjs+++ b/scripts/check-i18n-new-string-translations.test.mjs@@ -5,6 +5,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { describe, expect, test, vi } from 'vitest';+import { configureTestGitRepository } from '../test-support/configure-git-fixture.test-helper.ts';import {findTranslationGaps,formatReport,@@ -307,6 +308,7 @@ describe('invocation environment', () => {try {const decoy = join(scratch, 'decoy');gitAt(['init', '--quiet', decoy]);+ configureTestGitRepository(decoy);gitAt(['-c',diff --git a/scripts/check-known-reds.uncached.test.mjs b/scripts/check-known-reds.uncached.test.mjsindex e09c29ca9..934871ff1 100644--- a/scripts/check-known-reds.uncached.test.mjs+++ b/scripts/check-known-reds.uncached.test.mjs@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';import { afterAll, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../test-support/configure-git-fixture.test-helper.ts';import { okVitestBase } from '../test-support/vitest.base.ts';import { gitCleanEnv } from './git-clean-env.mjs';import {@@ -1268,6 +1269,7 @@ describe('known-reds through its real invocation', () => {windowsHide: true,encoding: 'utf8',});+ if (init.status === 0) configureTestGitRepository(root);test('scans test files and helpers that can declare their tests', () => {expect(init.status).toBe(0);diff --git a/scripts/compute-stable-version.test.mjs b/scripts/compute-stable-version.test.mjsindex 4a7734b44..af3156f21 100644--- a/scripts/compute-stable-version.test.mjs+++ b/scripts/compute-stable-version.test.mjs@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';import { dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';import { afterEach, describe, expect, test } from 'vitest';+import { configureTestGitRepository } from '../test-support/configure-git-fixture.test-helper.ts';import { loadChangesets, maxReleaseType } from './compute-next-beta.mjs';import {changesetIdsFromTreePaths,@@ -372,6 +373,7 @@ function committedChangesets(files, { subtree = '' } = {}) {writeFileSync(target, body);}git(root, ['init', '-q', '-b', 'main']);+ configureTestGitRepository(root);git(root, ['add', '-A']);git(root, ['-c', 'user.name=t', '-c', '[email protected]', 'commit', '-q', '-m', 'changesets']);return root;@@ -496,6 +498,7 @@ describe('the promote job computes the stable version with no node_modules at algit(root, ['tag', tagName]);};git(root, ['init', '-q', '-b', 'main']);+ configureTestGitRepository(root);commit('keep.md', bump(`"${OK}": patch`), 'v0.30.1');commit('new-thing.md', bump(`"${OK}": minor`), 'v0.30.2-beta.1');return root;diff --git a/scripts/create-turbo-cache-key.test.mjs b/scripts/create-turbo-cache-key.test.mjsindex f17112660..7af01ca8e 100644--- a/scripts/create-turbo-cache-key.test.mjs+++ b/scripts/create-turbo-cache-key.test.mjs@@ -4,8 +4,9 @@ import { tmpdir } from 'node:os';import { dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';import { afterAll, beforeAll, describe, expect, test } from 'vitest';-import { CACHE_KEY_FILE, cacheKey, writeCacheKey } from './create-turbo-cache-key.mjs';+import { configureTestGitRepository } from '../test-support/configure-git-fixture.test-helper.ts';import { withoutTurboAgentDetection } from '../test-support/turbo-agent-env.test-helper.mjs';+import { CACHE_KEY_FILE, cacheKey, writeCacheKey } from './create-turbo-cache-key.mjs';import { gitCleanEnv } from './git-clean-env.mjs';const OK_ROOT = fileURLToPath(new URL('..', import.meta.url));@@ -146,6 +147,7 @@ function fixture(globalDependencies) {)}\n`,);git(root, ['init', '-q']);+ configureTestGitRepository(root);git(root, ['add', '-A']);git(root, ['commit', '-q', '-m', 'fixture']);return root;diff --git a/test-support/configure-git-fixture.test-helper.ts b/test-support/configure-git-fixture.test-helper.tsnew file mode 100644index 000000000..c917badea--- /dev/null+++ b/test-support/configure-git-fixture.test-helper.ts@@ -0,0 +1,24 @@+import { execFileSync } from 'node:child_process';++const GIT_CONFIG_SPAWN_BUDGET_MS = 60_000;++export function configureTestGitRepository(repositoryPath: string): void;+export function configureTestGitRepository<T>(+ repositoryPath: string,+ executeGit: (args: readonly string[]) => T,+): T;+export function configureTestGitRepository<T>(+ repositoryPath: string,+ executeGit?: (args: readonly string[]) => T,+): T | void {+ const args = ['-C', repositoryPath, 'config', '--local', 'maintenance.auto', 'false'];+ if (executeGit) return executeGit(args);+ execFileSync('git', args, {+ env: Object.fromEntries(+ Object.entries(process.env).filter(([name]) => !name.startsWith('GIT_')),+ ),+ stdio: 'pipe',+ timeout: GIT_CONFIG_SPAWN_BUDGET_MS,+ killSignal: 'SIGKILL',+ });+}diff --git a/test-support/uncached-tier-reconcile.test.ts b/test-support/uncached-tier-reconcile.test.tsindex ed0998995..de4e155b1 100644--- a/test-support/uncached-tier-reconcile.test.ts+++ b/test-support/uncached-tier-reconcile.test.ts@@ -7,6 +7,7 @@ import { afterEach, beforeAll, describe, expect, onTestFinished, test, vi } fromimport { createVitest, type TestProject } from 'vitest/node';import { gitCleanEnv } from '../scripts/git-clean-env.mjs';import tierConfig from '../vitest.uncached.config';+import { configureTestGitRepository } from './configure-git-fixture.test-helper.ts';import { listUncachedTestFiles, uncachedTierProblems } from './uncached-tier-reconcile';const roots: string[] = [];@@ -258,6 +259,7 @@ describe("the tier's discovery domain: what git lists, and what every project ex'packages/server/src/cached.test.ts': '',});git(root, ['init', '-q']);+ configureTestGitRepository(root);git(root, ['add', '.gitignore', 'packages/server/src/tracked.uncached.test.ts']);git(root, ['commit', '-qm', 'base']);expect(listUncachedTestFiles(root).sort()).toEqual([@@ -276,6 +278,7 @@ describe("the tier's discovery domain: what git lists, and what every project ex'vitest.uncached.config.ts': '',});git(root, ['init', '-q']);+ configureTestGitRepository(root);expect(listUncachedTestFiles(root).sort()).toEqual([SERVER, TRANSPOSED].sort());});