mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
* test(mods): real-binary test tier with a scripted mock model (ADR-504) Runs the real `claude` binary headless against a local mock of the Anthropic Messages API, with ruflo-mods loaded through --plugin-dir in a throwaway project with its own HOME. No API key, no paid model. - mock-model.mjs: scripted Messages server (streaming and not), logs every request; untool'd or unknown requests get a minimal answer. - run.ts: runner with a minimal child environment, PATH recorders for dangerous commands, and readers for events, requests and files. - loads.test.ts (contract 1): with every option on, the heartbeat is written, /ruflo-mods is registered and answered with no model request. Negative control: a #4485-shaped copy (second bare session.start) is refused silently by the real loader and fails those assertions. - contracts.test.ts (contracts 2-5): verified-success record from a scripted fix turn; [RUFLO_LESSONS] reaches the request (and not below the gate); ruflo denies the root delete with its own reason and denies a listed command the engine allows (which runs without the plugin); the route block reaches the request (and not without the plugin). - Excluded from the CLI, v3 and root-ratchet default runs; run with `npm run test:real-binary`. New CI job mods-real-binary pins Claude Code 2.1.289 and fails, naming the step, if the binary will not start. Co-Authored-By: RuFlo <ruv@ruv.net> * docs(adr): ADR-504 status names PR #4589 Co-Authored-By: RuFlo <ruv@ruv.net> --------- Co-authored-by: r <r@x>
78 lines
3.5 KiB
TypeScript
78 lines
3.5 KiB
TypeScript
import { configDefaults, defineConfig } from 'vitest/config';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
export default defineConfig({
|
|
resolve: {
|
|
conditions: ['node'],
|
|
// Exercise the workspace security source rather than a stale installed
|
|
// package during cross-package policy integration tests (ADR-324).
|
|
// Subpath aliases must precede the bare package alias: Vite alias keys
|
|
// prefix-match, so '@claude-flow/security' alone would rewrite
|
|
// '@claude-flow/security/safe-git' to '.../src/index.ts/safe-git'.
|
|
alias: [
|
|
{
|
|
find: '@claude-flow/guidance/compiler',
|
|
replacement: fileURLToPath(new URL('../guidance/src/compiler.ts', import.meta.url)),
|
|
},
|
|
{
|
|
find: '@claude-flow/security/policy/index',
|
|
replacement: fileURLToPath(new URL('../security/src/policy/index.ts', import.meta.url)),
|
|
},
|
|
{
|
|
find: '@claude-flow/security/mcp-caller-identity',
|
|
replacement: fileURLToPath(new URL('../security/src/mcp-caller-identity.ts', import.meta.url)),
|
|
},
|
|
{
|
|
find: '@claude-flow/security/safe-git',
|
|
replacement: fileURLToPath(new URL('../security/src/safe-git.ts', import.meta.url)),
|
|
},
|
|
{
|
|
find: /^@claude-flow\/security$/,
|
|
replacement: fileURLToPath(new URL('../security/src/index.ts', import.meta.url)),
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
{
|
|
name: 'externalize-optional-deps',
|
|
enforce: 'pre',
|
|
resolveId(source) {
|
|
// Don't let Vite resolve optional deps that may have missing subpath
|
|
// exports. These are imported via try/catch dynamic import in src/
|
|
// (sona-optimizer falls back to no-SONA when the package isn't
|
|
// installed). External-marking them keeps vitest from failing
|
|
// module resolution at transform time.
|
|
if (source.startsWith('agentic-flow')) return { id: source, external: true };
|
|
if (source.startsWith('agentdb')) return { id: source, external: true };
|
|
// memory-bridge dynamic-imports this inside try/catch and degrades to
|
|
// the sql.js path; its dist is absent unless the workspace was built.
|
|
if (source === '@claude-flow/memory') return { id: source, external: true };
|
|
if (source.startsWith('@ruvector/')) return { id: source, external: true };
|
|
if (source.startsWith('@huggingface/transformers')) return { id: source, external: true };
|
|
if (source.startsWith('@xenova/transformers')) return { id: source, external: true };
|
|
return null;
|
|
},
|
|
},
|
|
],
|
|
test: {
|
|
environment: 'node',
|
|
include: ['__tests__/**/*.test.ts'],
|
|
// The real-binary tier (ADR-504) needs the `claude` binary; it has its own config and CI job
|
|
// (vitest.real-binary.config.ts, `npm run test:real-binary`, mods-real-binary in mod-guidance.yml).
|
|
exclude: [...configDefaults.exclude, '__tests__/real-binary/**'],
|
|
globals: true,
|
|
// Vitest's 5s default is unrealistic for this suite: a number of the
|
|
// memory/intelligence tests initialise a real ONNX embedder and a SQLite
|
|
// database. In isolation they finish quickly, but the full suite saturates
|
|
// every core (~440% CPU), and under that contention they exceeded 5s and
|
|
// failed with "Test timed out in 5000ms" — never an assertion failure.
|
|
// Because it depended on scheduling, a different file timed out on each
|
|
// run, which read as flakiness rather than a fixed timeout being too tight.
|
|
testTimeout: 30_000,
|
|
hookTimeout: 30_000,
|
|
coverage: {
|
|
enabled: false,
|
|
},
|
|
},
|
|
});
|