mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 00:52:18 +03:00
Retargetado para release/v3.8.51 (release/v3.8.50 está congelada — freeze issue #11439). Validado em lote combinado (batch-0824h2, junto de #11435/#11436/#11437) contra o tip de release/v3.8.51: typecheck:core limpo, gates estáticos OK, 127/127 testes focados passando. Investigação sólida com repro real via container isolado, três causas independentes identificadas e corrigidas com testes de regressão dedicados para cada uma. Obrigado pela contribuição!
98 lines
3.4 KiB
TypeScript
98 lines
3.4 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
resolveAudioCapability,
|
|
resolveVideoCapability,
|
|
} from "../../src/lib/modelCapabilityModalities.ts";
|
|
import {
|
|
MODALITY_BRIDGE_DEFAULTS,
|
|
resolveVideoBridgeRuntimeSettings,
|
|
} from "../../src/shared/constants/modalityBridgeDefaults.ts";
|
|
import { updateSettingsSchema } from "../../src/shared/validation/settingsSchemas.ts";
|
|
|
|
test("audio and video capability resolution trusts explicit catalog data before modalities", () => {
|
|
assert.equal(resolveAudioCapability({ supportsAudio: false }, null, ["audio"]), false);
|
|
assert.equal(resolveVideoCapability(undefined, { supportsVideo: true }, ["text"]), true);
|
|
assert.equal(resolveVideoCapability(undefined, null, ["text", "video"]), true);
|
|
assert.equal(resolveVideoCapability(undefined, null, ["text"]), false);
|
|
assert.equal(resolveVideoCapability(undefined, null, []), null);
|
|
});
|
|
|
|
test("Video Bridge settings default to a bounded disabled runtime and accept valid overrides", () => {
|
|
assert.deepEqual(resolveVideoBridgeRuntimeSettings({}), {
|
|
enabled: false,
|
|
model: "",
|
|
analysisMode: "full",
|
|
frameCount: 8,
|
|
samplingPolicy: "uniform",
|
|
maxVideos: 1,
|
|
timeoutMs: 120_000,
|
|
cacheEnabled: MODALITY_BRIDGE_DEFAULTS.cacheEnabled,
|
|
cacheTtlMinutes: MODALITY_BRIDGE_DEFAULTS.cacheTtlMinutes,
|
|
cacheMaxEntries: MODALITY_BRIDGE_DEFAULTS.cacheMaxEntries,
|
|
});
|
|
|
|
const valid = updateSettingsSchema.safeParse({
|
|
modalityBridgeVideoEnabled: true,
|
|
modalityBridgeVideoAnalysisMode: "focused",
|
|
modalityBridgeVideoModel: "openai/gpt-4o-mini",
|
|
modalityBridgeVideoFrameCount: 16,
|
|
modalityBridgeVideoSamplingPolicy: "scene_aware",
|
|
modalityBridgeVideoMaxVideos: 4,
|
|
modalityBridgeVideoTimeout: 120_000,
|
|
});
|
|
assert.equal(valid.success, true);
|
|
assert.equal(
|
|
resolveVideoBridgeRuntimeSettings({ modalityBridgeVideoAnalysisMode: "focused" }).analysisMode,
|
|
"focused"
|
|
);
|
|
assert.equal(
|
|
resolveVideoBridgeRuntimeSettings({
|
|
modalityBridgeVideoAnalysisMode: "instructions-from-media",
|
|
}).analysisMode,
|
|
"full"
|
|
);
|
|
assert.equal(
|
|
updateSettingsSchema.safeParse({ modalityBridgeVideoSamplingPolicy: "segment_aware" }).success,
|
|
true
|
|
);
|
|
});
|
|
|
|
test("Video Bridge settings schema rejects values outside extraction bounds", () => {
|
|
for (const [field, value] of Object.entries({
|
|
modalityBridgeVideoAnalysisMode: "instructions-from-media",
|
|
modalityBridgeVideoFrameCount: 17,
|
|
modalityBridgeVideoMaxVideos: 0,
|
|
modalityBridgeVideoTimeout: 120_001,
|
|
})) {
|
|
assert.equal(
|
|
updateSettingsSchema.safeParse({ [field]: value }).success,
|
|
false,
|
|
`${field}=${value} should be rejected`
|
|
);
|
|
}
|
|
});
|
|
|
|
test("persisted legacy Video Bridge timeouts clamp to the broker's 120 second deadline", () => {
|
|
for (const timeoutMs of [180_000, 300_000]) {
|
|
assert.equal(
|
|
resolveVideoBridgeRuntimeSettings({ modalityBridgeVideoTimeout: timeoutMs }).timeoutMs,
|
|
120_000
|
|
);
|
|
assert.equal(
|
|
updateSettingsSchema.safeParse({ modalityBridgeVideoTimeout: timeoutMs }).success,
|
|
false,
|
|
`new writes must reject ${timeoutMs}ms instead of exceeding the broker deadline`
|
|
);
|
|
}
|
|
});
|
|
|
|
test("persisted segment-aware policy remains an explicit opt-in", () => {
|
|
assert.equal(
|
|
resolveVideoBridgeRuntimeSettings({ modalityBridgeVideoSamplingPolicy: "segment_aware" })
|
|
.samplingPolicy,
|
|
"segment_aware"
|
|
);
|
|
});
|