Files
OmniRoute/tests/unit/compression/output-styles-catalog.test.ts
Moseyuh333 d43e71613e optimize(chaos+ponytail): i18n ponytail, dedupl dispatch, provider diversity (#8264)
* feat(chaos+ponytail): parallel chaos-mode dispatch + ponytail output style (rebased on v3.8.49)

- Chaos mode: new auto/chaos variant fans the prompt out to the top-N
  stable models in parallel and returns a single merged SSE stream.
  - Progressive streaming: each panel model's answer is enqueued as it
    lands (omni-chaos-part event), instead of awaiting the whole panel.
  - withTimeout now aborts the underlying request (modelAbortSignal) on
    timeout so the connection is released, not leaked.
  - concatSseText parses both OpenAI and Anthropic SSE wire formats.
  - autoPrefix/modePacks add the chaos-mode weight pack; virtualFactory
    materializes auto/chaos with fusion strategy + chaos config flag.
- Ponytail (lazy-senior-dev mode) integrated into the existing
  OUTPUT_STYLE_CATALOG registry (id 'ponytail') so it rides the production
  output-style injector, instead of a bespoke duplicate module. Dev-only
  scripts and the duplicate ponytail/ module are removed.
- Tests: chaosEngine/chaosVirtualCombo cover panel dispatch, progressive
  broadcast, timeout abort, and Anthropic parsing; autoCombo pack count
  updated to 6.

Rebased onto release/v3.8.49 (no provider-registry or validation changes —
those are split out per review).

* optimize(chaos+ponytail): i18n ponytail, dedupl chaos dispatch, provider diversity

- Ponytail: add vi/ja/pt-BR/id i18n with lite/full/ultra levels
- chaosEngine: extract dispatchOnePanelModel (shared), add onResult for
  progressive SSE streaming, fix withTimeout anti-pattern
- virtualFactory: deduplicate chaos panel by provider, add tuning overrides
- dispatchChaosFromCombo: accept ChaosTuning, enforce minPanel
- Add/port 8 node-runner tests for ponytail i18n + catalog integrity
- Add muse-spark-web.ts to KNOWN_MISSING_ERROR_HELPER (pre-existing)

* fix(8264): use HandleSingleModel type in chaosEngine dispatch (base-drift)

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
2026-07-23 11:21:53 -03:00

52 lines
1.9 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import {
OUTPUT_STYLE_CATALOG,
OUTPUT_STYLE_IDS,
outputStyleMeta,
type OutputStyle,
} from "../../../open-sse/services/compression/outputStyles/catalog.ts";
test("catalog seeds terse-prose, less-code, ponytail, terse-cjk with all three levels", () => {
for (const id of ["terse-prose", "less-code", "ponytail", "terse-cjk"]) {
const meta = outputStyleMeta(id);
assert.ok(meta, `${id} present`);
assert.equal(typeof meta.label, "string");
for (const level of ["lite", "full", "ultra"] as const) {
assert.equal(typeof meta.levels[level], "string");
assert.ok(meta.levels[level].length > 0, `${id}.${level} non-empty`);
}
}
});
test("OUTPUT_STYLE_IDS lists every catalog id in catalog (declaration) order", () => {
assert.deepEqual(OUTPUT_STYLE_IDS, Object.keys(OUTPUT_STYLE_CATALOG));
});
test("terse-cjk carries a locale gate of zh", () => {
assert.equal(outputStyleMeta("terse-cjk").locale, "zh");
assert.equal(outputStyleMeta("terse-prose").locale, undefined);
});
test("extensibility: one entry added to the catalog is enumerated with no other change", () => {
const probe: OutputStyle = {
id: "__probe__",
label: "Probe",
levels: { lite: "L", full: "F", ultra: "U" },
};
const extended = { ...OUTPUT_STYLE_CATALOG, [probe.id]: probe };
const ids = Object.keys(extended);
assert.ok(ids.includes("__probe__"));
// Adding a style adds exactly one id; no plumbing edited.
assert.equal(ids.length, OUTPUT_STYLE_IDS.length + 1);
});
test("every level instruction is deterministic (no Date/Math.random tokens)", () => {
for (const id of OUTPUT_STYLE_IDS) {
const meta = outputStyleMeta(id);
for (const level of ["lite", "full", "ultra"] as const) {
assert.doesNotMatch(meta.levels[level], /Date\.now|Math\.random|\$\{/);
}
}
});