Files
gbrain/test/ai/voyage-code-3-recipe.test.ts
T
54a0629745 v0.37.8.0 feat: voyage-code-3 discoverability + reindex-code cost-preview fix (#1267)
* v0.37.6.0 feat: voyage-code-3 discoverability + reindex-code cost-preview fix

For agents indexing source code with gbrain, the right embedding model
is now obvious — and the brain tells you so out loud. Decision tree +
Topology 3 doc + Topology 3 setup-skill pointer + runtime stderr nudge
from `gbrain reindex --code` against non-code-tuned models. Same diff
fixes the stale hardcoded `text-embedding-3-large` in the cost preview
that would have made the nudge land badly.

Tests: 3 new files (recipe regression, nudge logic + CLI integration,
cost-preview IRON-RULE regression).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* todos: file pre-existing doctor-report-remote score regression (#1215 follow-up)

Noticed during /ship of v0.37.6.0. The skill_brain_first check added in
v0.37.3.0 (#1215) appears to tank the doctor health score on fresh PGLite
test brains, causing test/doctor-report-remote.test.ts:65 to fail with
health_score: 50 (expects >=70). Pre-existing on master; not in this
branch's touch surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 08:59:29 -07:00

64 lines
2.8 KiB
TypeScript

/**
* v0.37.3 — voyage-code-3 registration regression pin.
*
* voyage-code-3 is the user-facing recommendation for gstack per-worktree
* code brains (Topology 3 in docs/architecture/topologies.md). The model
* was already registered before v0.37.3 but never surfaced as the right
* default for code indexing. These assertions guard against a future
* Voyage recipe refactor silently dropping voyage-code-3 from either the
* allowlist or the flexible-dim set.
*
* Also pins voyage-code-3 on the SDK-supported `dimensions` field path
* via dimsProviderOptions() — that's the v0.33.1.0 wire-key bug class.
*/
import { describe, expect, test } from 'bun:test';
import { getRecipe } from '../../src/core/ai/recipes/index.ts';
import {
supportsVoyageOutputDimension,
isValidVoyageOutputDim,
dimsProviderOptions,
VOYAGE_VALID_OUTPUT_DIMS,
} from '../../src/core/ai/dims.ts';
describe('recipe: voyage — voyage-code-3 registration', () => {
test('voyage-code-3 is in the embedding touchpoint models list', () => {
const r = getRecipe('voyage');
expect(r).toBeDefined();
expect(r!.touchpoints.embedding).toBeDefined();
expect(r!.touchpoints.embedding!.models).toContain('voyage-code-3');
});
test('voyage-code-3 supports flexible output dimensions', () => {
expect(supportsVoyageOutputDimension('voyage-code-3')).toBe(true);
});
test('all four canonical Voyage dims are accepted', () => {
// The set is locked at 256/512/1024/2048 — flexible-dim Voyage models
// (incl. voyage-code-3) accept exactly this set. Pinning each one
// catches the v0.33.1.0-class regression where a Voyage flexible-dim
// model accidentally falls back to default 1024 because dim validation
// drifts.
for (const dims of [256, 512, 1024, 2048]) {
expect(isValidVoyageOutputDim(dims)).toBe(true);
}
expect([...VOYAGE_VALID_OUTPUT_DIMS]).toEqual([256, 512, 1024, 2048]);
});
test('dimsProviderOptions returns SDK-shape dimensions field (not output_dimension wire-key)', () => {
// The v0.33.1.0 bug class: sending Voyage's `output_dimension` wire-key
// through the AI SDK gets silently dropped (SDK doesn't recognize it),
// Voyage falls back to default 1024, and any brain configured for
// 2048 silently embeds at the wrong width. The fix in v0.33.1.1 routes
// through the SDK-supported `dimensions` field; the voyageCompatFetch
// shim then translates to output_dimension on the wire.
const opts = dimsProviderOptions('openai-compatible', 'voyage-code-3', 1024);
expect(opts).toBeDefined();
// Shape: { openaiCompatible: { dimensions: 1024 } }
expect(opts).toHaveProperty('openaiCompatible.dimensions', 1024);
// Negative regression: no output_dimension on the providerOptions surface
const raw = JSON.stringify(opts);
expect(raw).not.toContain('output_dimension');
});
});