mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-07 07:42:13 +03:00
fix(api): accept all catalog engines on compression PUT schema (#6792)
Reconstructed onto release/v3.8.47 to drop unrelated main-drift (deps/electron/proxy files belong to #6620, not this PR). Resolved the release's OmniGlyph engine addition additively (types.ts/compression.ts kept both 'relevance' and 'omniglyph') and extended stackedPipelineStepSchema + STACKED_PIPELINE_ENGINE_INTENSITIES with the omniglyph branch so the ENGINE_CATALOG-parity test passes. Co-authored-by: Pitchfork-and-Torch <Pitchfork-and-Torch@users.noreply.github.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
This commit is contained in:
@@ -141,6 +141,19 @@ export const ultraConfigSchema = z
|
||||
|
||||
const noConfigSchema = z.object({}).strict();
|
||||
|
||||
// Structural engines (session-dedup / ccr / headroom / relevance / llmlingua) do not
|
||||
// expose a fixed intensity enum in ENGINE_CATALOG — accept optional free-form intensity
|
||||
// and a loose config bag so GET→PUT round-trips of stackedPipeline succeed (#6747).
|
||||
const structuralStepConfigSchema = z.record(z.string(), z.unknown()).optional();
|
||||
|
||||
/**
|
||||
* Writable stacked-pipeline step shape for PUT /api/settings/compression and
|
||||
* PUT /api/context/combos/[id]. MUST accept every engine id in ENGINE_CATALOG /
|
||||
* GET /api/compression/engines and every engine the DB normalizer keeps
|
||||
* (src/lib/db/compression.ts STACKED_PIPELINE_ENGINE_IDS). Issue #6747: a 5-engine
|
||||
* discriminator rejected session-dedup/ccr/headroom/relevance/llmlingua on write even
|
||||
* though GET returned them.
|
||||
*/
|
||||
export const stackedPipelineStepSchema = z.discriminatedUnion("engine", [
|
||||
z
|
||||
.object({
|
||||
@@ -159,7 +172,8 @@ export const stackedPipelineStepSchema = z.discriminatedUnion("engine", [
|
||||
z
|
||||
.object({
|
||||
engine: z.literal("aggressive"),
|
||||
intensity: z.literal("standard").optional(),
|
||||
// #6747: previously only "standard"; GET / engines.level may echo "ultra"
|
||||
intensity: z.enum(["standard", "ultra"]).optional(),
|
||||
config: aggressiveConfigSchema.optional(),
|
||||
})
|
||||
.strict(),
|
||||
@@ -177,6 +191,48 @@ export const stackedPipelineStepSchema = z.discriminatedUnion("engine", [
|
||||
config: rtkConfigSchema.optional(),
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
engine: z.literal("session-dedup"),
|
||||
intensity: z.string().optional(),
|
||||
config: structuralStepConfigSchema,
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
engine: z.literal("ccr"),
|
||||
intensity: z.string().optional(),
|
||||
config: structuralStepConfigSchema,
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
engine: z.literal("headroom"),
|
||||
intensity: z.string().optional(),
|
||||
config: structuralStepConfigSchema,
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
engine: z.literal("relevance"),
|
||||
intensity: z.string().optional(),
|
||||
config: structuralStepConfigSchema,
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
engine: z.literal("llmlingua"),
|
||||
intensity: z.string().optional(),
|
||||
config: structuralStepConfigSchema,
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
engine: z.literal("omniglyph"),
|
||||
intensity: z.string().optional(),
|
||||
config: structuralStepConfigSchema,
|
||||
})
|
||||
.strict(),
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -185,17 +241,23 @@ export const stackedPipelineStepSchema = z.discriminatedUnion("engine", [
|
||||
* dropdowns and `stackedPipelineStepSchema`: every engine/intensity offered here is,
|
||||
* by construction, accepted by the API update schema.
|
||||
*
|
||||
* Do NOT add an engine here that is not a branch of `stackedPipelineStepSchema` — the
|
||||
* `PUT /api/context/combos/[id]` route validates against that discriminated union and
|
||||
* would reject the payload with HTTP 400 (#4955: the UI previously offered `headroom`,
|
||||
* `session-dedup`, `ccr`, `llmlingua`, none of which the union accepts, so selecting
|
||||
* one silently failed the save). The parity is guarded by a unit test.
|
||||
* Every ENGINE_CATALOG id must appear here (empty intensity list = no level selector).
|
||||
* Parity with `stackedPipelineStepSchema` is guarded by unit tests (#4955 / #6747).
|
||||
* #4955 fixed a UI/schema drift by shrinking the UI; #6747 expands the schema so the
|
||||
* full catalog (and GET stackedPipeline) can round-trip on PUT.
|
||||
*/
|
||||
export const STACKED_PIPELINE_ENGINE_INTENSITIES: Record<string, readonly string[]> = {
|
||||
rtk: ["minimal", "standard", "aggressive"],
|
||||
caveman: ["lite", "full", "ultra"],
|
||||
// Order matches ENGINE_CATALOG stackPriority for readability
|
||||
"session-dedup": [],
|
||||
ccr: [],
|
||||
lite: ["lite"],
|
||||
aggressive: ["standard"],
|
||||
rtk: ["minimal", "standard", "aggressive"],
|
||||
headroom: [],
|
||||
relevance: [],
|
||||
caveman: ["lite", "full", "ultra"],
|
||||
aggressive: ["standard", "ultra"],
|
||||
llmlingua: [],
|
||||
omniglyph: [],
|
||||
ultra: ["ultra"],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user