mirror of
https://github.com/garrytan/gbrain.git
synced 2026-08-14 00:48:18 +00:00
test(e2e): complete the embedding.ts mock export surface for the cycle-sync import path
The wave's sync changes make the cycle sync phase lazily import commands/sync.ts, whose static embedding.ts imports must all resolve against the test's module mock (a missing name is a load-time SyntaxError). Stubs mirror the real pure functions.
This commit is contained in:
@@ -48,6 +48,16 @@ mock.module('../../src/core/embedding.ts', () => ({
|
||||
estimateEmbeddingCostUsd: (tokens: number) => (tokens / 1000) * 0.00013,
|
||||
// v0.41.31: embed phase reads the current signature to stamp provenance.
|
||||
currentEmbeddingSignature: () => 'text-embedding-3-large:1536',
|
||||
// The cycle sync phase reaches commands/sync.ts, whose static embedding.ts
|
||||
// imports must all resolve against this mock (missing names are a load-time
|
||||
// SyntaxError, not a runtime undefined).
|
||||
currentEmbeddingPricePerMTok: () => 0.13,
|
||||
willEmbedSynchronously: (opts: { v2Enabled: boolean; serialFlag: boolean; noEmbed: boolean }) => {
|
||||
const effectiveNoEmbed = opts.v2Enabled && !opts.serialFlag && !opts.noEmbed ? true : opts.noEmbed;
|
||||
return effectiveNoEmbed ? 'deferred' : 'inline';
|
||||
},
|
||||
shouldBlockSync: (costUsd: number, floorUsd: number, mode: string, posture: 'gated' | 'tokenmax' = 'gated') =>
|
||||
posture === 'tokenmax' ? false : mode === 'inline' && costUsd > floorUsd,
|
||||
}));
|
||||
|
||||
const { runCycle, ALL_PHASES } = await import('../../src/core/cycle.ts');
|
||||
|
||||
Reference in New Issue
Block a user