mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 10:52:17 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
81 lines
3.2 KiB
TypeScript
81 lines
3.2 KiB
TypeScript
/**
|
|
* Guard for the self-targeting-PR check (gap 23).
|
|
*
|
|
* PR #8912 has head == base == release/v3.8.50 — a PR from a branch to itself. No diff, can
|
|
* never merge, and it sits in the queue with a full check board attached, burning review
|
|
* attention and CI minutes on every push to that branch. It survived precisely because nothing
|
|
* looks wrong: the checks pass (there is nothing to check) and mergeability just reads unknown.
|
|
*
|
|
* The distinction these tests protect is the one that makes the check safe to block on: an
|
|
* equal head/base BRANCH is conclusive, an equal head/base SHA is not. A branch cut moments ago
|
|
* has an identical tip and is perfectly legitimate — failing on that would block real work.
|
|
*/
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
// @ts-expect-error — plain .mjs gate script, no type declarations by design
|
|
import { classifyPrTarget } from "../../scripts/check/check-pr-self-target.mjs";
|
|
|
|
test("the #8912 shape is rejected: same branch on both sides", () => {
|
|
const r = classifyPrTarget({
|
|
headRef: "release/v3.8.50",
|
|
baseRef: "release/v3.8.50",
|
|
headSha: "abc1234567",
|
|
baseSha: "abc1234567",
|
|
});
|
|
assert.equal(r.verdict, "self-targeting");
|
|
assert.match(r.reason, /release\/v3\.8\.50/);
|
|
assert.match(r.reason, /never merge/);
|
|
});
|
|
|
|
test("a normal PR passes", () => {
|
|
const r = classifyPrTarget({
|
|
headRef: "fix/something",
|
|
baseRef: "release/v3.8.50",
|
|
headSha: "aaaaaaaaaa",
|
|
baseSha: "bbbbbbbbbb",
|
|
});
|
|
assert.equal(r.verdict, "ok");
|
|
});
|
|
|
|
test("equal SHAs on DIFFERENT branches only warn — a fresh branch cut is legitimate", () => {
|
|
// This is the case that must not block: branch created, nothing pushed yet.
|
|
const r = classifyPrTarget({
|
|
headRef: "fix/just-cut",
|
|
baseRef: "release/v3.8.50",
|
|
headSha: "cccccccccc",
|
|
baseSha: "cccccccccc",
|
|
});
|
|
assert.equal(r.verdict, "empty-diff", "must NOT be self-targeting");
|
|
assert.match(r.reason, /nothing to review yet/);
|
|
});
|
|
|
|
test("branch equality wins over SHA difference", () => {
|
|
// Same branch but the tip moved between the two reads — still self-targeting.
|
|
const r = classifyPrTarget({
|
|
headRef: "release/v3.8.50",
|
|
baseRef: "release/v3.8.50",
|
|
headSha: "aaaaaaaaaa",
|
|
baseSha: "bbbbbbbbbb",
|
|
});
|
|
assert.equal(r.verdict, "self-targeting");
|
|
});
|
|
|
|
test("no PR context is a skip, not a failure", () => {
|
|
// The same job runs on push and workflow_dispatch, where these vars are empty.
|
|
assert.equal(classifyPrTarget({}).verdict, "no-pr-context");
|
|
assert.equal(classifyPrTarget({ headRef: "", baseRef: "" }).verdict, "no-pr-context");
|
|
assert.equal(classifyPrTarget().verdict, "no-pr-context");
|
|
});
|
|
|
|
test("whitespace does not create a false pass", () => {
|
|
const r = classifyPrTarget({ headRef: " release/v3.8.50 ", baseRef: "release/v3.8.50" });
|
|
assert.equal(r.verdict, "self-targeting", "a stray space must not disguise the same branch");
|
|
});
|
|
|
|
test("only one ref present is not conclusive either way", () => {
|
|
// Half a signal must not fail the PR — the check blocks, so it has to be certain.
|
|
assert.equal(classifyPrTarget({ headRef: "fix/x", baseRef: "" }).verdict, "ok");
|
|
assert.equal(classifyPrTarget({ headRef: "", baseRef: "main" }).verdict, "ok");
|
|
});
|