Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url';

const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../../..');
const FLEET_ROOT = resolve(REPO_ROOT, '..');
const DEFAULT_FREE_AI_REPO = resolve(FLEET_ROOT, 'free-ai');
export const DEFAULT_FREE_AI_REPO = resolve(FLEET_ROOT, 'free-ai');

export const REQUIRED_MODELS = [
{ id: 'gemini-embedding-001', provider: 'gemini', dimensions: 1536, aliases: ['text-embedding-3-small', 'text-embedding-3-large', 'text-embedding-004'] },
Expand Down
15 changes: 12 additions & 3 deletions cloudflare/worker/tests/audit-free-ai-embedding-contract.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { mkdtempSync, mkdirSync, rmSync, writeFileSync, existsSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
import { auditFreeAiEmbeddingContract } from '../scripts/audit-free-ai-embedding-contract.mjs';
import {
auditFreeAiEmbeddingContract,
DEFAULT_FREE_AI_REPO,
} from '../scripts/audit-free-ai-embedding-contract.mjs';

// The "current sibling" check reads the real free-ai repo on disk (fleet sibling).
// It runs in local dev where free-ai is checked out alongside; CI checks out
// knowledge-base alone, so skip it there. The fixture-based tests below still
// cover the audit logic.
const siblingFreeAiPresent = existsSync(DEFAULT_FREE_AI_REPO);

function makeFreeAiRepo() {
const freeAiRepo = mkdtempSync(resolve(tmpdir(), 'kb-free-ai-contract-'));
Expand Down Expand Up @@ -55,7 +64,7 @@ const embeddings = EMBEDDING_CANDIDATES.map((candidate) => ({
}

describe('audit-free-ai-embedding-contract', () => {
it('passes for the current sibling free-ai contract', () => {
it.skipIf(!siblingFreeAiPresent)('passes for the current sibling free-ai contract', () => {
const report = auditFreeAiEmbeddingContract();

expect(report.ok).toBe(true);
Expand Down
Loading