fix: validate compaction config pairs
This commit is contained in:
@@ -80,7 +80,9 @@ declare module 'cordis' {
|
||||
|
||||
/** Replay owner for one service-wide estimator and isolated per-session folds. */
|
||||
export class TokenMeterService extends Service {
|
||||
static Config: z<TokenMeterConfig> = z.object({})
|
||||
// Schemastery preserves untrusted loader keys on an empty object schema;
|
||||
// the public type excludes settings while validateConfigKeys rejects them.
|
||||
static Config: z<TokenMeterConfig> = z.object({}) as unknown as z<TokenMeterConfig>
|
||||
|
||||
private readonly states = new WeakMap<Session, ReplayState>()
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import type { TokenUsage } from '@deepseek-ai/dsh-llm'
|
||||
|
||||
/** Token-meter plugin configuration; the fixed estimator has no settings. */
|
||||
export type TokenMeterConfig = object
|
||||
export type TokenMeterConfig = Record<string, never>
|
||||
|
||||
/** The baseline from which a signed surface delta produces current pressure. */
|
||||
export type TokenMeasurementBaseline =
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, expectTypeOf, it } from 'vitest'
|
||||
import { Context } from 'cordis'
|
||||
import { CallId } from '@deepseek-ai/dsh-llm'
|
||||
import type { ContentBlock, Message, TokenUsage } from '@deepseek-ai/dsh-llm'
|
||||
@@ -87,10 +87,15 @@ function expectSurfaceTotal(measurement: TokenMeasurement): void {
|
||||
}
|
||||
|
||||
describe('TokenMeterService configuration and registration', () => {
|
||||
it('exposes an empty public configuration type', () => {
|
||||
expectTypeOf<{}>().toExtend<TokenMeterConfig>()
|
||||
expectTypeOf<{ contextWindow: number }>().not.toExtend<TokenMeterConfig>()
|
||||
})
|
||||
|
||||
it.each(['models', 'contextWindow', 'contextWidow'])(
|
||||
'rejects stale or unknown top-level config key %s',
|
||||
(key) => {
|
||||
expect(() => meter({ [key]: {} }))
|
||||
expect(() => meter({ [key]: {} } as unknown as TokenMeterConfig))
|
||||
.toThrow(`TokenMeterConfig: unknown key "${key}"`)
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user