mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-11 22:53:04 +00:00
* fix(lbug): robust Windows lock acquisition for CI integration tests
LadybugDB's `new Database()` raises `Could not set lock on file` from
local_file_system.cpp synchronously inside the constructor — before any
query is issued, so `withLbugDb`'s query-time retry never sees it. On
Windows CI this surfaces as flaky integration tests due to AV-scanner
holds, libuv handle-release lag, and stale `.wal` sidecars from aborted
prior runs.
This change closes the gap at *open time*:
- `openLbugConnection` now wraps `new lbug.Database()` in a bounded
busy-retry (5x100ms back-off) inside `lbug-config.ts`. Errors that
exhaust the budget are tagged via `LBUG_OPEN_RETRY_EXHAUSTED` so
`withLbugDb`'s outer 3x retry skips re-retrying a freshly-exhausted
path (eliminates the 3x5=15-attempt / ~6s tail latency).
- For recognized test fixtures only (immediate-parent dir matches a
known prefix AND resolves under `os.tmpdir()`), one final stale-
sidecar sweep removes `.wal`/`.lock` and retries once. Production
paths never enter this branch.
- `safeClose` on Windows runs a bounded `fs.open` probe to absorb
native handle-release lag; logs a warning if the probe exhausts so
operators can spot AV interference.
- `isDbBusyError` is now defined in `lbug-config.ts` as the single
source of truth, re-exported from `lbug-adapter.ts` for compatibility.
- New tests cover open-time retry (happy/retry/exhaust/non-busy/tag),
stale-sidecar sweep (test-fixture-only, production-rejection,
preserves-original-error), `isTestFixturePath` direct unit suite
(accept/reject/traversal/nested/trailing-sep), and
`waitForWindowsHandleRelease` (openable/ENOENT/no-leak).
- The two new test files are added to vitest's existing serialized
`lbug-db` project (already `fileParallelism: false`).
Closes the chronic Windows CI flake on lbug-touching integration tests
while preserving the existing single-writable-Database-per-process
LadybugDB contract. No public API surface changed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(lbug): drop isDbBusyError re-export, import from lbug-config directly
The re-export from lbug-adapter.ts was a transitional convenience — with
the matcher now living in lbug-config.ts, having two import paths for the
same symbol invites future drift. Updated the two real consumers
(lbug-lock-retry.test.ts, lbug-open-retry.test.ts) to import from
lbug-config directly, removed the re-export equality test (now vacuous),
and refreshed the explanatory comment so it no longer references a
re-export pattern that doesn't exist.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(lbug): silence benign LadybugDB v0.16.1 schema-init lock warnings on Windows
doInitLbug logs "⚠️ Schema creation warning: ... Could not set lock on
file" on every CREATE NODE TABLE call after the first init on a given
dbPath, on Windows. The lock is internal to LadybugDB v0.16.1 and is
resolved before the table is created — same tolerance pattern as the
existing "already exists" filter. Genuine cross-process lock contention
still surfaces on the next operation through withLbugDb's retry, so
filtering at the schema-init catch only suppresses noise, not signal.
Also extend the safeClose Windows handle-release probe to cover the
.wal sidecar (the previous Database's WAL handle was the slowest to
release, surfacing as the schema-query lock contention) and switch the
probe back to 'r+' so it actually detects exclusive locks.
Test loop in lbug-close-handle-release.test.ts simplified to 10 plain
iterations now that the underlying noise is filtered upstream.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(lbug): isDbBusyError review fixes
- Drop redundant `could not set lock` term — already subsumed by `lock`.
- Document the intentionally-broad matcher: graph-DB lock-shaped errors
("deadlock", "unlock failed", "lock contention", "could not open lock
file") are all treated as transient. If a non-transient surfaces,
tighten the matcher rather than raise the retry budget.
- Add positive test cases covering those lock-shaped strings so the
intent is visible and a future tightening would deliberately break
these.
- Fix the open-retry back-off comment: max sleep is 100+200+300+400 =
1000ms (no sleep after the final attempt), not 1.5s.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
113 lines
4.5 KiB
TypeScript
113 lines
4.5 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
// Shared settings — inherited by all projects via extends: true
|
|
testTimeout: 30000,
|
|
hookTimeout: 120000,
|
|
pool: 'forks',
|
|
globals: true,
|
|
teardownTimeout: 3000,
|
|
// N-API destructors can crash worker forks on macOS during process exit.
|
|
// This is independent of the QueryResult lifetime fix in @ladybugdb/core 0.15.2 —
|
|
// it's a vitest forks + native addon interaction where destructors run in
|
|
// arbitrary order at exit. Tests themselves pass; only the exit crashes.
|
|
// TODO: remove once LadybugDB fixes all N-API destructor ordering issues.
|
|
dangerouslyIgnoreUnhandledErrors: true,
|
|
|
|
// Coverage stays at root (not supported in project configs)
|
|
coverage: {
|
|
provider: 'v8',
|
|
include: ['src/**/*.ts'],
|
|
exclude: [
|
|
'src/cli/index.ts', // CLI entry point (commander wiring)
|
|
'src/server/**', // HTTP server (requires network)
|
|
'src/core/wiki/**', // Wiki generation (requires LLM)
|
|
],
|
|
// Auto-ratchet: vitest bumps thresholds when coverage exceeds them.
|
|
// CI will fail if a PR drops below these floors.
|
|
thresholds: {
|
|
statements: 26,
|
|
branches: 23,
|
|
functions: 28,
|
|
lines: 27,
|
|
},
|
|
},
|
|
|
|
// LadybugDB's native mmap addon causes file-lock conflicts when vitest
|
|
// runs lbug test files in parallel forks on Windows. The 'lbug-db'
|
|
// project forces sequential execution (fileParallelism: false).
|
|
//
|
|
// Each file runs in its own fork — the fork exits after the file
|
|
// completes, triggering an N-API destructor segfault that is caught
|
|
// by dangerouslyIgnoreUnhandledErrors. Tests themselves pass; only
|
|
// the exit crashes. This is safer than isolate: false, which causes
|
|
// native state corruption after 2-3 open/close cycles in the same fork.
|
|
projects: [
|
|
{
|
|
extends: true,
|
|
test: {
|
|
name: 'lbug-db',
|
|
include: [
|
|
'test/integration/lbug-core-adapter.test.ts',
|
|
'test/integration/lbug-vector-extension.test.ts',
|
|
'test/integration/lbug-pool.test.ts',
|
|
'test/integration/lbug-pool-stability.test.ts',
|
|
'test/integration/local-backend.test.ts',
|
|
'test/integration/local-backend-calltool.test.ts',
|
|
'test/integration/search-core.test.ts',
|
|
'test/integration/search-pool.test.ts',
|
|
'test/integration/augmentation.test.ts',
|
|
'test/integration/staleness-and-stability.test.ts',
|
|
'test/integration/lbug-lock-retry.test.ts',
|
|
'test/integration/lbug-open-retry.test.ts',
|
|
'test/integration/lbug-close-handle-release.test.ts',
|
|
'test/integration/api-impact-e2e.test.ts',
|
|
'test/integration/shape-check-regression.test.ts',
|
|
'test/integration/java-class-impact.test.ts',
|
|
'test/integration/class-impact-all-languages.test.ts',
|
|
],
|
|
fileParallelism: false,
|
|
sequence: { groupOrder: 1 },
|
|
},
|
|
},
|
|
{
|
|
extends: true,
|
|
test: {
|
|
name: 'default',
|
|
sequence: { groupOrder: 3 },
|
|
include: ['test/**/*.test.ts'],
|
|
exclude: [
|
|
'test/integration/lbug-core-adapter.test.ts',
|
|
'test/integration/lbug-vector-extension.test.ts',
|
|
'test/integration/lbug-pool.test.ts',
|
|
'test/integration/lbug-pool-stability.test.ts',
|
|
'test/integration/local-backend.test.ts',
|
|
'test/integration/local-backend-calltool.test.ts',
|
|
'test/integration/search-core.test.ts',
|
|
'test/integration/search-pool.test.ts',
|
|
'test/integration/augmentation.test.ts',
|
|
'test/integration/staleness-and-stability.test.ts',
|
|
'test/integration/lbug-lock-retry.test.ts',
|
|
'test/integration/lbug-open-retry.test.ts',
|
|
'test/integration/lbug-close-handle-release.test.ts',
|
|
'test/integration/api-impact-e2e.test.ts',
|
|
'test/integration/shape-check-regression.test.ts',
|
|
'test/integration/java-class-impact.test.ts',
|
|
'test/integration/class-impact-all-languages.test.ts',
|
|
'test/integration/skills-e2e.test.ts',
|
|
],
|
|
},
|
|
},
|
|
{
|
|
extends: true,
|
|
test: {
|
|
name: 'cli-e2e',
|
|
include: ['test/integration/skills-e2e.test.ts'],
|
|
fileParallelism: false,
|
|
sequence: { groupOrder: 2 },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|