Files
OmniRoute/open-sse/services/autoCombo/__tests__/chaosVirtualCombo.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

50 lines
2.0 KiB
TypeScript

/**
* Integration-style test: confirms the `auto/chaos` virtual auto-combo is
* materialized with the right shape so the chat handler will fan it out in
* parallel via the chaos engine.
*
* This exercises the real factory path (not a mock) so we know `auto/chaos`
* advertises correctly in /v1/models and routes through combo.ts → handleChaosChat.
*/
import { describe, it, expect } from "vitest";
import { createVirtualAutoCombo } from "../virtualFactory";
import { AUTO_TEMPLATE_VARIANTS } from "../builtinCatalog";
import { parseAutoPrefix } from "../autoPrefix";
describe("auto/chaos virtual combo", () => {
it("is registered in the built-in catalog", () => {
expect(AUTO_TEMPLATE_VARIANTS["auto/chaos"]).toBe("chaos");
expect(AUTO_TEMPLATE_VARIANTS["auto/best-chaos"]).toBe("chaos");
});
it("parses as a valid auto prefix", () => {
const parsed = parseAutoPrefix("auto/chaos");
expect(parsed.valid).toBe(true);
expect(parsed.variant).toBe("chaos");
});
it("materializes with fusion strategy + chaos config", async () => {
const combo = await createVirtualAutoCombo("chaos");
expect(combo.type).toBe("auto");
expect(combo.strategy).toBe("auto");
expect(combo.config?.chaos?.enabled).toBe(true);
// panel is capped to a sane size
expect((combo.models ?? []).length).toBeGreaterThan(0);
expect((combo.models ?? []).length).toBeLessThanOrEqual(5);
// judge (primary) is the first panel model
expect(combo.config?.chaos?.judgeModel).toBe(combo.models?.[0]?.model);
// tuning config is present (may have undefined fields from env vars)
expect(combo.config?.chaos?.tuning).toBeDefined();
});
it("deduplicates panel models by provider for diversity", async () => {
const combo = await createVirtualAutoCombo("chaos");
const models = combo.models ?? [];
const providers = models.map((m) => m.providerId);
const uniqueProviders = new Set(providers);
// No provider should appear more than once in the chaos panel.
expect(providers.length).toBe(uniqueProviders.size);
});
});