fix(core): name EMBEDDING_PROVIDER in the mock-embedding warning (UF-058)

When no embedding provider answers, the banner told users to set
HIVE_MIND_EMBEDDING_PROVIDER, which only the hive-mind CLI read; Waggle
reads EMBEDDING_PROVIDER. A test checks the banner text.
This commit is contained in:
shumeiko.it
2026-11-01 00:43:05 +01:00
parent c098f20872
commit 9276723f25
3 changed files with 28 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
* createEmbeddingProvider tests: the generic mock fallback, dimension respect,
* deterministic-vector behavior, batch shape and the reprobe contract.
*/
import { describe, it, expect } from 'vitest';
import { describe, it, expect, vi } from 'vitest';
import {
createEmbeddingProvider,
capEmbedText,
@@ -12,6 +12,22 @@ import {
import type { Embedder } from '../../src/embeddings/embeddings.js';
describe('createEmbeddingProvider', () => {
it('names the environment variable Waggle reads in the mock fallback banner', async () => {
const previous = process.env.WAGGLE_SUPPRESS_EMBEDDING_WARNING;
delete process.env.WAGGLE_SUPPRESS_EMBEDDING_WARNING;
const write = vi.spyOn(process.stderr, 'write').mockImplementation(() => true);
try {
await createEmbeddingProvider({ provider: 'mock' });
const banner = write.mock.calls.map(([chunk]) => String(chunk)).join('');
expect(banner).toContain('EMBEDDING_PROVIDER=inprocess');
expect(banner).not.toContain('HIVE_MIND_EMBEDDING_PROVIDER');
} finally {
write.mockRestore();
if (previous === undefined) delete process.env.WAGGLE_SUPPRESS_EMBEDDING_WARNING;
else process.env.WAGGLE_SUPPRESS_EMBEDDING_WARNING = previous;
}
});
it('falls back to mock when provider=mock is requested explicitly', async () => {
const provider = await createEmbeddingProvider({ provider: 'mock' });
expect(provider.getActiveProvider()).toBe('mock');