mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 14:22:09 +03:00
* chore(ci): add .mergify.yml to main — Mergify only reads config from the default branch (#7168)
* fix(ci): add the auto-enqueue pull_request_rule to the Mergify config (queue_conditions alone are eligibility-only) (#7179)
* fix(ci): migrate Mergify auto-enqueue to merge_protections_settings.auto_merge_conditions (rules-based path is EOL 2026-07-16) (#7216)
* fix(ci): drop Mergify batch settings (batching is a paid-tier feature; free plan queue is serial) (#7220)
* fix(ci): merge queue tolerates the advisory dast-smoke failure (its GH-hosted build hang dequeued every attempt) (#7225)
* test(ci): make the #6634 selfref guard hermetic — main's copy hard-fails every PR (#7341)
main's copy of this test still does git I/O inside a unit test:
const baseSrc = git(['show', 'origin/main:' + FILE]);
Runners check out a shallow single ref, so origin/main does not resolve and the
test dies with 'fatal: invalid object name origin/main'. Every PR into main
fails Unit Tests (7/8) on it — today that is #7313, #7315, #7316, #7334, #7336
and #7337, six PRs red on a defect none of them introduced. #7313 has no other
red at all.
release/v3.8.49 already carries a fix (2e42b8efc, #7174: try/catch, fetch
origin/main on demand, t.skip() when unreachable), but it only reaches main at
release time — so main stays broken for the whole cycle. Cherry-picking it would
also import a new problem: PR Test Policy classifies t.skip() as a silenced
assertion, which we watched it correctly catch on #7300 today.
This is the hermetic version instead (ported from #7327, which does the same for
the release branch): read the file straight off disk, compare against an empty
base so baseTaut/baseExtTaut are 0 — the strictest possible comparison point —
and call evaluateMasking() directly. No git ref, no fetch, no skip, nothing the
runner's checkout depth can break.
The #6634 regression stays covered: the guard's logic lives in
SELF_TEST_FIXTURE_RE (check-test-masking.mjs:337), not in the test. Proven both
ways on main before committing — neutralise SELF_TEST_FIXTURE_RE to /$^/ and
the test FAILS; restore it and it passes 2/2, with check-test-masking.mjs left
byte-identical.
Co-authored-by: growab <nekron@icloud.com>
* chore(quality): tighten main's coverage baseline to the CI's real numbers (#7347)
main's ratchet had been failing --require-tighten on every PR: 11 metrics
improved but the baseline was never tightened. Same class as the #6634
selfref guard — an infra fix that lands only on the release branch leaves
main red for the whole cycle, and every PR into main pays for it.
Values are the merged-coverage numbers from a run on main itself (a local
run measures ~68% vs CI's ~80%; the baseline's own note warns about that
gap). Only the 11 coverage values change — gitleaks and semgrepFindings
keep main's own state.
No changelog fragment: #7326 carries it on release/v3.8.49, and a second
one here would double the entry at release time.
* fix(models): update Anthropic model contextLength to 1M
Opus 4.6, Sonnet 4.6, and Sonnet 5 all have 1M context
window since GA (2026-03-13). Update:
- agyModels + antigravityModelAliases: 200000 -> 1048576 (binary 1M, matches existing convention in those files)
- claude registry: 200000 -> 1000000 (decimal 1M, matches other entries in that file)
Older models (opus-4-5, sonnet-4-5, haiku-4-5) and defaultContextLength: 200000 left untouched.
Signed-off-by: Minxi Hou <houminxi@gmail.com>
* fix(claude): add sonnet-4-6 to CONTEXT_1M_SUPPORTED_MODELS
Sonnet 4.6 has 1M context GA since 2026-02-17. Without this entry, the CC-compatible wire image omits the context-1m beta header for Sonnet 4.6 requests, causing large-context requests to be rejected by Anthropic.
* test: regression test for CONTEXT_1M_SUPPORTED_MODELS allowlist
Verify that every Claude model with contextLength > 200K has a
matching entry in the beta header allowlist, and vice versa.
Parses source files directly (no module imports needed).
Signed-off-by: Minxi Hou <houminxi@gmail.com>
* test: improve regression test with empty-registry guard
Add sanity check that parser finds at least one model. Handle type annotations in CONTEXT_1M_SUPPORTED_MODELS assignment. Remove weaker subagent test.
Signed-off-by: Minxi Hou <houminxi@gmail.com>
* test: update stale contextLength expectations for the 1M Sonnet/Opus 4.6 fix
Three pre-existing tests hardcoded the old 200000 contextLength for
claude-opus-4-6-thinking / claude-sonnet-4-6 / claude-sonnet-5, which this
PR's own registry change (agyModels.ts, antigravityModelAliases.ts, claude
registry) legitimately bumped to 1M GA:
- antigravity-model-aliases.test.ts: deepEqual assertions for
claude-opus-4-6-thinking and claude-sonnet-5 in the Antigravity catalog
expected contextLength: 200000; now 1048576. Added an explicit contextLength
assertion for claude-sonnet-4-6 too.
- auto-combo-context-advertising.test.ts: resolveComboContextLimit regression
test asserted the claude target's own limit as 200000; the test's intent
(own limit wins over an 8k sibling, not compressed) is unchanged, only the
registry's current correct value (1000000) needed updating. Also refreshed
a stale comment in the MAX-of-candidates test (functionally unaffected,
since gemini's 1048576 already wins either way).
- models-catalog-route.test.ts: refreshed a stale inline comment (the actual
assertion checks the MIN across combo targets, 128000, unaffected by the
1M bump).
Verified via Anthropic's own docs (platform.claude.com/docs/en/build-with-claude/context-windows):
"Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, Claude Sonnet 5, and
Claude Sonnet 4.6 have a 1M-token context window ... on the Claude API,
Amazon Bedrock, Google Cloud, and Microsoft Foundry" -- matches this PR's
claimed 2026-03-13 GA date exactly, and Google Cloud coverage corroborates
the Antigravity-hosted ids. Independently corroborated for the
Antigravity-specific path by unrelated third-party projects fixing the same
gap (earendil-works/pi#2209, badlogic/pi-mono#2194).
Swept the full test suite for other contextLength/contextWindow assertions
against these three model ids (grep + targeted runs across
models-catalog-route, model-capabilities-registry, t31-t33-t34-t38-model-specs,
executor-antigravity, agy-provider, provider-models-config,
model-metadata-registry, claude-web-sonnet5-registry, combo-routing-engine,
command-code-executor, combo-lockout-quota-reset -- 157 tests green); the
Bedrock-hosted registry and modelSpecs.ts module were already correctly at
1000000 for these models, reinforcing this PR's direction.
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
---------
Signed-off-by: Minxi Hou <houminxi@gmail.com>
Co-authored-by: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: growab <nekron@icloud.com>
Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>
215 lines
8.8 KiB
TypeScript
215 lines
8.8 KiB
TypeScript
/**
|
|
* TDD regression tests — auto-combo context-window advertising + per-target
|
|
* combo compression limit (the "premature auto compaction" bug).
|
|
*
|
|
* Bug chain (discussion report: coding agents "keep forgetting things"):
|
|
* 1. /api/combos/auto never exposed context_length, so the opencode plugin
|
|
* advertised `limit: { context: 0 }` for auto combos. opencode disables
|
|
* its smart auto-compaction entirely when context === 0, letting the
|
|
* conversation grow until OmniRoute's destructive purifyHistory() drops
|
|
* old messages silently.
|
|
* 2. chatCore's proactive-compression block overrode the per-target context
|
|
* limit with min(...allComboTargets) even though chatCore always executes
|
|
* with the CONCRETE target's provider/model (handleSingleModel resolves
|
|
* the target before calling chatCore) — compressing at the smallest
|
|
* target's window while running on the largest target.
|
|
*
|
|
* Fixes under test:
|
|
* - virtualFactory.computeAdvertisedLimits(): MAX of candidates' known
|
|
* context windows (the auto-combo context pre-filter routes oversized
|
|
* requests to large-window candidates, so MAX is safe to advertise).
|
|
* - GET /api/combos/auto includes context_length / max_output_tokens.
|
|
* - contextManager.resolveComboContextLimit(): prefers the executing
|
|
* target's own limit; min(...targets) only as a defensive fallback when
|
|
* the current provider/model resolves no specific limit.
|
|
*/
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-auto-combo-ctx-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
process.env.API_KEY_SECRET = process.env.API_KEY_SECRET ?? "auto-combo-ctx-test-secret";
|
|
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
const settingsDb = await import("../../src/lib/db/settings.ts");
|
|
|
|
const virtualFactory = await import("../../open-sse/services/autoCombo/virtualFactory.ts");
|
|
const contextManager = await import("../../open-sse/services/contextManager.ts");
|
|
const combosAutoRoute = await import("../../src/app/api/combos/auto/route.ts");
|
|
|
|
test.after(() => {
|
|
core.resetDbInstance();
|
|
try {
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
} catch {
|
|
// best-effort cleanup
|
|
}
|
|
});
|
|
|
|
// ── virtualFactory.computeAdvertisedLimits ───────────────────────────────────
|
|
|
|
test("computeAdvertisedLimits returns MAX of candidates' known context windows", () => {
|
|
const { computeAdvertisedLimits } = virtualFactory as unknown as {
|
|
computeAdvertisedLimits: (candidates: Array<{ provider: string; model: string }>) => {
|
|
contextLength: number | null;
|
|
maxOutputTokens: number | null;
|
|
};
|
|
};
|
|
assert.equal(
|
|
typeof computeAdvertisedLimits,
|
|
"function",
|
|
"virtualFactory should export computeAdvertisedLimits()"
|
|
);
|
|
|
|
// gemini has registry defaultContextLength=1048576; claude-sonnet-4-6 has 1000000 (#7129:
|
|
// 1M GA per Anthropic docs) -- gemini's binary-1M window still wins as the MAX.
|
|
const result = computeAdvertisedLimits([
|
|
{ provider: "claude", model: "claude-sonnet-4-6" },
|
|
{ provider: "gemini", model: "gemini-2.5-pro" },
|
|
]);
|
|
assert.equal(result.contextLength, 1048576, "MAX of candidate windows should win");
|
|
assert.ok(
|
|
typeof result.maxOutputTokens === "number" && result.maxOutputTokens > 0,
|
|
"maxOutputTokens should be a positive number"
|
|
);
|
|
});
|
|
|
|
test("computeAdvertisedLimits returns null limits for an empty candidate pool", () => {
|
|
const { computeAdvertisedLimits } = virtualFactory as unknown as {
|
|
computeAdvertisedLimits: (candidates: Array<{ provider: string; model: string }>) => {
|
|
contextLength: number | null;
|
|
maxOutputTokens: number | null;
|
|
};
|
|
};
|
|
const result = computeAdvertisedLimits([]);
|
|
assert.equal(result.contextLength, null);
|
|
assert.equal(result.maxOutputTokens, null);
|
|
});
|
|
|
|
test("computeAdvertisedLimits never returns 0 for a non-empty pool (unknown models fall back)", () => {
|
|
const { computeAdvertisedLimits } = virtualFactory as unknown as {
|
|
computeAdvertisedLimits: (candidates: Array<{ provider: string; model: string }>) => {
|
|
contextLength: number | null;
|
|
maxOutputTokens: number | null;
|
|
};
|
|
};
|
|
const result = computeAdvertisedLimits([
|
|
{ provider: "totally-unknown-provider", model: "mystery-model" },
|
|
]);
|
|
assert.ok(
|
|
typeof result.contextLength === "number" && result.contextLength > 0,
|
|
`unknown candidates should fall back to a positive default, got ${result.contextLength}`
|
|
);
|
|
});
|
|
|
|
// ── GET /api/combos/auto advertises context_length ──────────────────────────
|
|
|
|
test("GET /api/combos/auto includes positive context_length for combos with candidates", async () => {
|
|
await settingsDb.updateSettings({ requireLogin: false });
|
|
|
|
const req = new Request("http://localhost/api/combos/auto", { method: "GET" });
|
|
const res = await combosAutoRoute.GET(req as never);
|
|
const body = await res.json();
|
|
|
|
assert.equal(res.status, 200);
|
|
assert.ok(Array.isArray(body.combos), "body.combos should be an array");
|
|
assert.ok(body.combos.length > 0, "should list at least the default auto combo");
|
|
|
|
for (const combo of body.combos) {
|
|
if ((combo.candidateCount ?? 0) > 0) {
|
|
assert.ok(
|
|
typeof combo.context_length === "number" && combo.context_length > 0,
|
|
`combo ${combo.id} with ${combo.candidateCount} candidates must advertise a positive context_length, got ${combo.context_length}`
|
|
);
|
|
assert.ok(
|
|
typeof combo.max_output_tokens === "number" && combo.max_output_tokens > 0,
|
|
`combo ${combo.id} must advertise a positive max_output_tokens, got ${combo.max_output_tokens}`
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
// ── contextManager.resolveComboContextLimit (per-target compression limit) ──
|
|
|
|
test("resolveComboContextLimit prefers the executing target's own limit over combo min", () => {
|
|
const { resolveComboContextLimit } = contextManager as unknown as {
|
|
resolveComboContextLimit: (opts: {
|
|
provider: string;
|
|
model: string | null;
|
|
comboTargetLimits: number[];
|
|
}) => { limit: number; source: string };
|
|
};
|
|
assert.equal(
|
|
typeof resolveComboContextLimit,
|
|
"function",
|
|
"contextManager should export resolveComboContextLimit()"
|
|
);
|
|
|
|
// Executing on gemini (1048576 provider default) while the combo also has
|
|
// a tiny 32k target: compression must use the EXECUTING target's window.
|
|
const result = resolveComboContextLimit({
|
|
provider: "gemini",
|
|
model: "gemini-2.5-pro",
|
|
comboTargetLimits: [32000, 1048576],
|
|
});
|
|
assert.equal(result.limit, 1048576, "must not regress to min(...targets) on a known target");
|
|
assert.equal(result.source, "target");
|
|
});
|
|
|
|
test("resolveComboContextLimit regression: claude target must not be compressed at an 8k sibling", () => {
|
|
const { resolveComboContextLimit } = contextManager as unknown as {
|
|
resolveComboContextLimit: (opts: {
|
|
provider: string;
|
|
model: string | null;
|
|
comboTargetLimits: number[];
|
|
}) => { limit: number; source: string };
|
|
};
|
|
const result = resolveComboContextLimit({
|
|
provider: "claude",
|
|
model: "claude-sonnet-4-6",
|
|
comboTargetLimits: [8000],
|
|
});
|
|
// #7129: claude-sonnet-4-6's own registry limit is 1M GA (was 200000) -- the point of this
|
|
// regression test is that the target's OWN limit wins over the 8k sibling, not the specific
|
|
// magic number, so the expectation tracks the registry's current (correct) value.
|
|
assert.equal(result.limit, 1000000);
|
|
assert.equal(result.source, "target");
|
|
});
|
|
|
|
test("resolveComboContextLimit falls back to combo min when the target has no specific limit", () => {
|
|
const { resolveComboContextLimit } = contextManager as unknown as {
|
|
resolveComboContextLimit: (opts: {
|
|
provider: string;
|
|
model: string | null;
|
|
comboTargetLimits: number[];
|
|
}) => { limit: number; source: string };
|
|
};
|
|
const result = resolveComboContextLimit({
|
|
provider: "totally-unknown-provider",
|
|
model: "mystery-model",
|
|
comboTargetLimits: [32000, 200000],
|
|
});
|
|
assert.equal(result.limit, 32000, "unknown target should defensively use min of combo targets");
|
|
assert.equal(result.source, "combo-min");
|
|
});
|
|
|
|
test("resolveComboContextLimit uses generic fallback when nothing else is known", () => {
|
|
const { resolveComboContextLimit } = contextManager as unknown as {
|
|
resolveComboContextLimit: (opts: {
|
|
provider: string;
|
|
model: string | null;
|
|
comboTargetLimits: number[];
|
|
}) => { limit: number; source: string };
|
|
};
|
|
const result = resolveComboContextLimit({
|
|
provider: "totally-unknown-provider",
|
|
model: "mystery-model",
|
|
comboTargetLimits: [],
|
|
});
|
|
assert.equal(result.limit, 128000, "generic default fallback");
|
|
assert.equal(result.source, "fallback");
|
|
});
|