mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-29 23:37:41 +00:00
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Gitleaks / gitleaks (push) Waiting to run
Publish / Classify release event (push) Waiting to run
Publish / RC guard (marker + release-PR skip) (push) Blocked by required conditions
Publish / ci (push) Blocked by required conditions
Publish / Publish to npm (push) Blocked by required conditions
Publish / Build & Push RC Docker images (push) Blocked by required conditions
Scorecard / Scorecard analysis (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-cli) (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-web) (push) Waiting to run
* fix: rebuild changed graphs in fresh databases Populated-table writes inflate LadybugDB storage (#3852). Bulk-load fresh graphs while retaining parse caches, no-ops and logical counts. Read prior graphs without writes so staging failures preserve their bytes. Restore compatible vectors and rebuild derived layers and FTS under the existing checkpoint and publication guards. Keep the write policy, preservation guards and regressions together so the replacement has one coherent publication contract. Closes #3852 * perf: skip FTS builds for empty tables * fix: align CI with compact graph writes Validate populated-table FTS coverage and cached full writes while keeping the performance budget unchanged. Compare database bytes without enumerating Buffer keys, and retain native checkpoint failure details. * perf: use bounded hybrid graph writes Keep small edits selective and scale the mutation budget with graph size. Compact accumulated native storage growth without copying every graph on every edit. Preserve physical receipts across shared-store publication and native resource limits during recovery. Align CI assertions with selective writes and populated FTS tables. Refs #3852 * fix: close hybrid compaction gaps Count removed rows before selective writes and preserve the shared graph's compaction receipt when publishing completed vectors. * test: serialize compaction native suites * test: declare capped count determinism * test: mock persisted rows in FTS fixtures * fix: address hybrid write review (#3854) Retain unreadable graph bytes before recovery and stop destructive writes when the real embedding cache probe fails. Keep small deletions and renames selective, preserve healthy private graphs through edit/revert cycles, and bound FTS presence probes. Cover durability, footprint boundaries and vector restoration. Align mock graph fixtures and fix the pre-existing WAL test's UUID false positive found by full-suite validation; its nine-test suite now passes. * test: clarify selective restore fixture (#3854) * test: isolate recovery CI fixtures (#3854) Cap embedding generation in the missing-graph recovery fixture so it does not require optional model packages. Allow cold PowerShell startup in the OS identity smoke test; retain the five-second production probe limit. * test: finish review cleanup (#3854) * test: strengthen graph integrity checks Hash persisted node and edge properties; clean failed fixtures and gate FTS setup through the test lifecycle. Refs #3854 --------- Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
111 lines
4 KiB
JavaScript
111 lines
4 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { spawnSync } from 'node:child_process';
|
|
import { createRequire } from 'node:module';
|
|
import {
|
|
copyFile,
|
|
mkdir,
|
|
mkdtemp,
|
|
readFile,
|
|
readdir,
|
|
realpath,
|
|
rm,
|
|
writeFile,
|
|
} from 'node:fs/promises';
|
|
import { existsSync } from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
|
|
// Run from gitnexus/ after npm pack. Each manager installs the actual PR tarball
|
|
// without lifecycle scripts, reproducing bunx's missing native install copy.
|
|
const tarballs = (await readdir('.')).filter((name) => /^gitnexus-.*\.tgz$/.test(name));
|
|
assert.equal(tarballs.length, 1, 'Expected one freshly packed gitnexus tarball');
|
|
const tarball = path.resolve(tarballs[0]);
|
|
|
|
function run(program, args, cwd, env) {
|
|
// All shell arguments are fixed literals; the tarball is copied through fs.
|
|
// Windows package-manager entrypoints are .cmd shims.
|
|
const result = spawnSync(program, args, {
|
|
cwd,
|
|
env,
|
|
shell: process.platform === 'win32',
|
|
encoding: 'utf8',
|
|
maxBuffer: 16 * 1024 * 1024,
|
|
});
|
|
if (result.error || result.status !== 0) {
|
|
throw new Error(
|
|
`${program} ${args.join(' ')} failed (${result.status}): ${result.error?.message ?? ''}\n` +
|
|
`${result.stdout ?? ''}\n${result.stderr ?? ''}`,
|
|
);
|
|
}
|
|
return result.stdout;
|
|
}
|
|
|
|
for (const manager of ['npm', 'pnpm', 'bun']) {
|
|
const root = await mkdtemp(path.join(os.tmpdir(), `gitnexus-${manager}-smoke-`));
|
|
const env = {
|
|
...process.env,
|
|
GITNEXUS_HOME: path.join(root, 'home'),
|
|
GITNEXUS_STORAGE_PATH: path.join(root, 'repo', '.gitnexus'),
|
|
GITNEXUS_SHARED_STORE: 'off',
|
|
GITNEXUS_MEMORY: undefined,
|
|
SCARF_ANALYTICS: 'false',
|
|
};
|
|
try {
|
|
const version = run(manager, ['--version'], root, env).trim();
|
|
await copyFile(tarball, path.join(root, 'gitnexus.tgz'));
|
|
await writeFile(
|
|
path.join(root, 'package.json'),
|
|
JSON.stringify({
|
|
name: 'gitnexus-manager-smoke',
|
|
version: '1.0.0',
|
|
private: true,
|
|
dependencies: { gitnexus: 'file:./gitnexus.tgz' },
|
|
}),
|
|
);
|
|
run(
|
|
manager,
|
|
['install', '--ignore-scripts', ...(manager === 'pnpm' ? ['--store-dir=store'] : [])],
|
|
root,
|
|
env,
|
|
);
|
|
|
|
const installed = await realpath(path.join(root, 'node_modules', 'gitnexus'));
|
|
const requireInstalled = createRequire(path.join(installed, 'package.json'));
|
|
const binaryPath = path.join(
|
|
path.dirname(requireInstalled.resolve('@ladybugdb/core')),
|
|
'lbugjs.node',
|
|
);
|
|
assert.equal(existsSync(binaryPath), false, `${manager}: fixture must skip native preparation`);
|
|
await mkdir(path.join(root, 'repo'));
|
|
await writeFile(
|
|
path.join(root, 'repo', 'index.ts'),
|
|
'export function greet(name: string) { return `Hello ${name}`; }\n' +
|
|
'export function main() { return greet("GitNexus"); }\n',
|
|
);
|
|
run('git', ['init', '-q', 'repo'], root, env);
|
|
const args = ['gitnexus', 'analyze', 'repo', '--index-only', '--workers', '1', '--verbose'];
|
|
const [program, prefix] =
|
|
manager === 'npm'
|
|
? ['npx', ['--no-install']]
|
|
: manager === 'pnpm'
|
|
? ['pnpm', ['exec']]
|
|
: ['bunx', ['--no-install']];
|
|
run(program, [...prefix, ...args], root, env);
|
|
assert.equal(existsSync(binaryPath), true, `${manager}: native binary was not prepared`);
|
|
const metadata = JSON.parse(
|
|
await readFile(path.join(root, 'repo', '.gitnexus', 'gitnexus.json'), 'utf8'),
|
|
);
|
|
assert.equal(metadata.stats.files, 1);
|
|
assert.ok(metadata.stats.nodes >= 4, `${manager}: missing indexed symbols`);
|
|
assert.ok(metadata.stats.edges >= 5, `${manager}: missing graph relationships`);
|
|
assert.ok(
|
|
metadata.runnerIdentity?.dependencyRuntime?.artifactCount > 0,
|
|
`${manager}: missing identity receipt`,
|
|
);
|
|
console.log(
|
|
`PASS ${process.platform}/${process.arch}: ${manager} ${version} installed and indexed the PR tarball`,
|
|
);
|
|
} finally {
|
|
await rm(root, { recursive: true, force: true });
|
|
}
|
|
}
|