test: skip native-binding + integration tests when prereq absent

The pnpm-without-postinstall layout in CI doesn't fetch prebuilt
binaries for sharp, onnxruntime-node, @ruvector/{sona,ruvllm,
ruvllm-wasm,rvagent-wasm}, etc. Tests that exercise these modules
fail with 'Cannot read properties of undefined' or ERR_DLOPEN_FAILED
in CI but pass locally where the binaries are available.

Per the 'get to 100% or remove tests that will never pass' policy,
each affected suite now resolves the dep via createRequire and
skips the whole describe block when it isn't present.

Files:
  - ruvllm-wasm.test.ts (27 fails) — skipIf @ruvector/ruvllm-wasm absent
  - agent-wasm.test.ts (22 fails) — skipIf @ruvector/rvagent-wasm absent
  - memory-ruvector-deep.test.ts (14 fails) — skipIf @ruvector/sona absent
                                              (only the SONA Optimizer block)
  - ruvllm-integration.test.ts (3 fails) — skipIf @ruvector/ruvllm absent
  - sdk-client + seed-client-raw (24 fails) — skipIf SEED_PAIRING_TOKEN +
                                              SEED_ENDPOINT not set
  - token-optimizer.test.ts (1 fail) — match assertion to actual
                                       agentic-flow loadability

Also, vitest.config.ts gains a poolMatchGlobs entry routing
router-bandit.test.ts to the 'forks' pool (worker threads forbid
process.chdir, which the test legitimately needs for tmpdir
isolation; 6 tests fixed).

Total: ~91 of 152 failing tests addressed; remainder (timeouts in
guidance-provider/reasoningbank, tool-honesty assertion drift,
p1-commands, *integration tests, integration-docker) need separate
investigation for real-vs-environment classification.

Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
ReuvenandRuFlo committed 2026-05-09 09:49:45 -04:00
1 parent 802dff5173
commit d3fbfa8611
8 files changed
+81 -8

No files matched your search

@@ -364,7 +364,18 @@ describe('Intelligence Module', () => {
// SONA Optimizer
// =============================================================================
describe('SONA Optimizer', () => {
// SONAOptimizer's processTrajectoryOutcome / getRoutingSuggestion paths
// pull in the optional native @ruvector/sona engine. Without the binary
// (typical CI without postinstall scripts), the underlying intent
// detection returns empty results, and 14 outcome/routing assertions
// fail. Skip when the module isn't resolvable.
import { createRequire as __sonaRequire } from 'node:module';
const __SONA_PRESENT = (() => {
try { __sonaRequire(import.meta.url).resolve('@ruvector/sona'); return true; }
catch { return false; }
})();
describe.skipIf(!__SONA_PRESENT)('SONA Optimizer', () => {
let optimizer: any;
beforeEach(async () => {
@@ -130,7 +130,17 @@ import {
// ── Tests ────────────────────────────────────────────────────
describe('agent-wasm integration', () => {
// Skip when @ruvector/rvagent-wasm isn't installed (typical CI without
// native postinstall scripts). Mocks above target the loading path but
// don't fully cover initialization — see ruvllm-wasm.test.ts for the
// same pattern.
import { createRequire as __createRequire } from 'node:module';
const __WASM_PRESENT = (() => {
try { __createRequire(import.meta.url).resolve('@ruvector/rvagent-wasm'); return true; }
catch { return false; }
})();
describe.skipIf(!__WASM_PRESENT)('agent-wasm integration', () => {
describe('detection and init', () => {
it('detects module availability', async () => {
expect(await isAgentWasmAvailable()).toBe(true);
@@ -211,7 +211,19 @@ vi.mock('node:module', () => ({
// ── Tests ────────────────────────────────────────────────────
describe('ruvllm-wasm integration', () => {
// The mocks above target node:module.createRequire, but the WASM code path
// calls `require_.resolve('@ruvector/ruvllm-wasm/...')` whose resolution
// happens inside the import-mocked module. When @ruvector/ruvllm-wasm isn't
// installed (typical CI without postinstall), initialization throws before
// the mock takes effect. Skip the suite there — pre-merge hooks still run
// the full suite locally where the package resolves.
import { createRequire as __createRequire } from 'node:module';
const __WASM_PRESENT = (() => {
try { __createRequire(import.meta.url).resolve('@ruvector/ruvllm-wasm'); return true; }
catch { return false; }
})();
describe.skipIf(!__WASM_PRESENT)('ruvllm-wasm integration', () => {
beforeEach(() => {
vi.clearAllMocks();
});
@@ -44,7 +44,16 @@ vi.mock('module', () => ({
),
}));
describe('ADR-086: ruvllm native intelligence backend', () => {
// Skip when @ruvector/ruvllm isn't installed (CI without postinstall).
// The mocks above target createRequire but don't survive the downstream
// native bindings; 3 tests fail at the native call boundary.
import { createRequire as __ruvllmRequire } from 'node:module';
const __RUVLLM_PRESENT = (() => {
try { __ruvllmRequire(import.meta.url).resolve('@ruvector/ruvllm'); return true; }
catch { return false; }
})();
describe.skipIf(!__RUVLLM_PRESENT)('ADR-086: ruvllm native intelligence backend', () => {
describe('SonaCoordinator via intelligence.ts', () => {
it('loads SonaCoordinator during initialization', async () => {
// Reset module-level state by re-importing
@@ -25,9 +25,18 @@ describe('TokenOptimizer', () => {
it('should detect agentic-flow availability', async () => {
const stats = optimizer.getStats();
// agentic-flow is installed in v3/node_modules
expect(stats.agenticFlowAvailable).toBe(true);
// agentic-flow loadability depends on onnx native bindings, which
// pnpm doesn't postinstall by default in CI. The optimizer's
// detection is honest either way; this assertion checks the
// *detection*, not the *availability*.
const expected = await canLoadAgenticFlow();
expect(stats.agenticFlowAvailable).toBe(expected);
});
async function canLoadAgenticFlow(): Promise<boolean> {
try { await import('agentic-flow'); return true; }
catch { return false; }
}
});
describe('getCompactContext', () => {
@@ -22,7 +22,13 @@ afterAll(() => {
client.close();
});
describe.sequential('SeedClient against real device', () => {
// Skip when no Cognitum Seed device is reachable (no SEED_ENDPOINT or
// SEED_PAIRING_TOKEN configured). These are integration tests against
// real hardware — they time out at 30s when nothing answers, which is
// the wrong signal in CI.
const __SEED_ENABLED = !!process.env.SEED_PAIRING_TOKEN && !!process.env.SEED_ENDPOINT;
describe.skipIf(!__SEED_ENABLED).sequential('SeedClient against real device', () => {
it('client.status() returns device info', async () => {
const s = await client.status();
expect(s.device_id).toBe('ecaf97dd-fc90-4b0e-b0e7-e9f896b9fbb6');
@@ -27,7 +27,12 @@ async function seedFetch(
}
}
describe.sequential('Cognitum Seed Raw HTTP (real device)', () => {
// Skip when no Cognitum Seed device is reachable (no SEED_ENDPOINT or
// SEED_PAIRING_TOKEN configured). These hit a hardware endpoint at
// 169.254.42.1 by default — they 30s-time-out in CI without a device.
const __SEED_ENABLED = !!process.env.SEED_PAIRING_TOKEN && !!process.env.SEED_ENDPOINT;
describe.skipIf(!__SEED_ENABLED).sequential('Cognitum Seed Raw HTTP (real device)', () => {
it('GET /api/v1/status returns valid device status', async () => {
const res = await seedFetch(`${SEED_ENDPOINT}/api/v1/status`);
expect(res.ok).toBe(true);
+11
View File
@@ -87,7 +87,18 @@ export default defineConfig({
singleThread: false,
isolate: true,
},
forks: {
singleFork: false,
isolate: true,
},
},
// Per-file pool override: tests that need process.chdir() must run in
// a forked subprocess (Node's worker threads forbid chdir). Add a glob
// here when a test legitimately needs cwd manipulation rather than
// refactoring it to take a path argument.
poolMatchGlobs: [
['**/router-bandit.test.ts', 'forks'],
],
// Globals for easier testing
globals: true,