~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
ci(dependabot): guard first-match-wins group ordering - specific groups before wildcards (#6914)
LearningCircuita52132830c2c
diff --git a/.github/dependabot.yml b/.github/dependabot.ymlindex b1a110d5ac..d4af300944 100644--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@ -78,6 +78,13 @@ updates:commit-message:prefix: "chore"include: "scope"+ # FIRST MATCH WINS: Dependabot assigns each dependency to the first+ # group whose patterns match, in this file's order. Any new specific+ # group (e.g. a lockstep version-pair group like vitest's) must be+ # defined ABOVE every broader group of the same applies-to (a "*"+ # wildcard or a glob such as "vite*"), or the broader group silently+ # captures its dependencies and the grouping has no effect (#6871).+ # tests/ci/test_dependabot_config.py checks this for every entry.groups:# Vitest plugins require the exact same version as vitest. Include# major updates so a new major cannot strand either side of the pair.diff --git a/tests/ci/test_dependabot_config.py b/tests/ci/test_dependabot_config.pyindex d98e2f9d2f..62119f3dbc 100644--- a/tests/ci/test_dependabot_config.py+++ b/tests/ci/test_dependabot_config.py@@ -1,12 +1,15 @@"""Regression tests for bounded Dependabot PR generation."""+import refrom pathlib import Path+import pytestimport yamlREPO_ROOT = Path(__file__).resolve().parents[2]DEPENDABOT_CONFIG = REPO_ROOT / ".github" / "dependabot.yml"+SEMVER_LEVELS = {"major", "minor", "patch"}TEST_NPM_DIRECTORIES = {"/tests","/tests/accessibility_tests",@@ -91,3 +94,298 @@ def test_npm_minor_patch_and_security_updates_are_grouped():"test-security",applies_to="security-updates",)+++def _glob_matches(glob, text):+ """Match like Dependabot: ``*`` is the only wildcard, case is ignored.++ ``text`` may be a pattern itself. Its ``*`` is then an ordinary+ character, and a match means ``glob`` takes every name ``text`` takes.+ """+ regex = ".*".join(re.escape(part) for part in glob.lower().split("*"))+ return re.fullmatch(regex, text.lower()) is not None+++def _covers_updates(first, second):+ """True when ``first`` takes every update ``second`` could take.++ Only ``update-types`` and ``dependency-type`` are read. An absent+ ``update-types`` means every semver level and an absent+ ``dependency-type`` both kinds, so groups split by them (minor and patch+ vs major, production vs development) do not cover each other. By+ ``update-types``, a group that lists only some semver levels does not+ cover one without them, but one that lists all three does. By+ ``dependency-type``, a group that has one covers only a group with the+ same one.+ """+ first_types = set(first.get("update-types") or SEMVER_LEVELS)+ second_types = set(second.get("update-types") or SEMVER_LEVELS)+ first_kind = first.get("dependency-type")+ second_kind = second.get("dependency-type")+ return second_types <= first_types and first_kind in (None, second_kind)+++def _hidden_groups(entry):+ """List ``(earlier, later, pattern)`` for patterns an earlier group takes.++ Dependabot gives a dependency to the FIRST group, in file order, that+ takes it, and groups of different ``applies-to`` never compete. Within+ one ``applies-to`` pool, a later group's pattern is reported when an+ earlier group has a glob that++ * is strictly broader: ``*`` and ``vite*`` hide ``vitest``, and ``@*``+ hides ``@vitest/*``. Neither group's ``update-types``,+ ``dependency-type`` or ``exclude-patterns`` is read here, so this can+ over-report (a ``*`` group limited to major updates still counts);+ moving the specific group above it is the fix; or+ * is equally broad and the earlier group's ``update-types`` and+ ``dependency-type`` cover the later group's (an absent key covers+ everything): the later group is a duplicate and never forms. Groups+ split by those keys (minor and patch vs major, production vs+ development) may share a glob, and so may a later group without them+ after a group they limit.++ A group without ``patterns`` is ``*``, and ``dependency-type`` is read as+ written even where the ecosystem ignores it. Not compared: groups that+ only partly overlap, by glob (``*test`` above ``vite*``) or by+ update-types (minor and patch above patch and major), since neither is+ the specific one; a later group that only several earlier groups+ together take; and ``exclude-patterns``, which are never read and so can+ only add reports.+ """+ groups = list((entry.get("groups") or {}).items())+ return [+ (earlier, later, pattern)+ for index, (earlier, first) in enumerate(groups)+ for later, second in groups[index + 1 :]+ if first.get("applies-to", "version-updates")+ == second.get("applies-to", "version-updates")+ for pattern in second.get("patterns") or ["*"]+ if any(+ _glob_matches(glob, pattern)+ and (+ not _glob_matches(pattern, glob)+ or _covers_updates(first, second)+ )+ for glob in first.get("patterns") or ["*"]+ )+ ]+++def test_specific_groups_precede_broader_groups_in_every_entry():+ """No dependabot group may sit below a group that already takes it.++ First match wins (#6871): a broader group defined above a narrower one+ silently captures the narrower group's dependencies, so the narrower+ grouping (the vitest lockstep pair is the concrete case) never forms+ and nothing reports an error. A repeated group never forms either.+ YAML maps load in document order, which is the file's order.+ """+ config = yaml.safe_load(DEPENDABOT_CONFIG.read_text(encoding="utf-8"))+ assert any(+ len(entry.get("groups") or {}) > 1 for entry in config["updates"]+ ), "no entry with several groups: the ordering check would be vacuous"+ for entry in config["updates"]:+ hidden = _hidden_groups(entry)+ assert not hidden, (+ f"dependabot entry "+ f"{entry.get('directory') or entry.get('directories')}: "+ f"{hidden} (earlier group, later group, hidden pattern) - "+ f"first-match-wins means the earlier group captures them. Keep "+ f"specific groups above broader ones, and give groups that "+ f"share a glob distinct update-types, dependency-type or "+ f"applies-to."+ )+++VITEST_GROUP = {"patterns": ["vitest", "@vitest/*"]}+MINOR_AND_PATCH = ["minor", "patch"]+++ ("broader", "hidden"),+ [+ pytest.param(+ {"patterns": ["*"]}, ["vitest", "@vitest/*"], id="exact-wildcard"+ ),+ pytest.param({"patterns": ["vite*"]}, ["vitest"], id="prefix-glob"),+ pytest.param({"patterns": ["@*"]}, ["@vitest/*"], id="scope-glob"),+ pytest.param(+ {"patterns": ["Vite*"]}, ["vitest"], id="glob-in-other-case"+ ),+ pytest.param(+ {"patterns": ["*", "x"]},+ ["vitest", "@vitest/*"],+ id="wildcard-plus-name",+ ),+ pytest.param(+ {"dependency-type": "production"},+ ["vitest", "@vitest/*"],+ id="dependency-type-only",+ ),+ pytest.param(+ {"patterns": ["*"], "update-types": MINOR_AND_PATCH},+ ["vitest", "@vitest/*"],+ id="limited-to-update-types",+ ),+ pytest.param(+ {"patterns": ["*"], "exclude-patterns": ["vitest", "@vitest/*"]},+ ["vitest", "@vitest/*"],+ id="excluding-the-patterns",+ ),+ ],+)+def test_guard_flags_a_broader_group_above_a_specific_one(broader, hidden):+ entry = {"groups": {"broad": broader, "vitest": VITEST_GROUP}}++ assert _hidden_groups(entry) == [+ ("broad", "vitest", pattern) for pattern in hidden+ ]+++ ("first", "second", "hidden"),+ [+ pytest.param(+ {"patterns": ["*"]},+ {"dependency-type": "production"},+ ["*"],+ id="dependency-type-only-below-wildcard",+ ),+ pytest.param(+ {"patterns": ["*"]},+ {"patterns": ["*"], "update-types": ["major"]},+ ["*"],+ id="wildcard-for-major-below-wildcard",+ ),+ pytest.param(+ {"patterns": ["*"]},+ {"patterns": ["*"], "exclude-patterns": ["x"]},+ ["*"],+ id="wildcard-excluding-below-wildcard",+ ),+ pytest.param(+ {"patterns": ["*"]},+ {"patterns": ["*"]},+ ["*"],+ id="wildcard-twice",+ ),+ pytest.param(+ VITEST_GROUP,+ VITEST_GROUP,+ ["vitest", "@vitest/*"],+ id="lockstep-pair-repeated-without-applies-to",+ ),+ pytest.param(+ {"patterns": ["Vitest"]},+ {"patterns": ["vitest"]},+ ["vitest"],+ id="same-name-in-other-case",+ ),+ pytest.param(+ {"patterns": ["*"], "update-types": MINOR_AND_PATCH},+ {"patterns": ["*"], "update-types": ["patch"]},+ ["*"],+ id="update-types-inside-the-earlier-group",+ ),+ pytest.param(+ {"patterns": ["*"], "update-types": ["major", "minor", "patch"]},+ {"patterns": ["*"]},+ ["*"],+ id="every-update-type-spelled-out",+ ),+ pytest.param(+ {"patterns": ["*"], "dependency-type": "production"},+ {"dependency-type": "production", "update-types": ["major"]},+ ["*"],+ id="same-dependency-type",+ ),+ ],+)+def test_guard_flags_a_group_the_earlier_one_takes_whole(first, second, hidden):+ entry = {"groups": {"first": first, "second": second}}++ assert _hidden_groups(entry) == [+ ("first", "second", pattern) for pattern in hidden+ ]+++ "groups",+ [+ pytest.param(+ {"vitest": VITEST_GROUP, "broad": {"patterns": ["*"]}},+ id="specific-first",+ ),+ pytest.param(+ {+ "broad": {"patterns": ["*"], "applies-to": "security-updates"},+ "vitest": VITEST_GROUP,+ },+ id="separate-pool",+ ),+ pytest.param(+ {+ "unscoped": {"patterns": ["vite*"]},+ "scoped": {"patterns": ["@vitest/*"]},+ },+ id="disjoint-globs",+ ),+ pytest.param(+ {+ "minor-and-patch": {+ "patterns": ["*"],+ "update-types": MINOR_AND_PATCH,+ },+ "major": {"patterns": ["*"], "update-types": ["major"]},+ },+ id="split-by-update-types",+ ),+ pytest.param(+ {+ "production": {"dependency-type": "production"},+ "development": {"dependency-type": "development"},+ },+ id="split-by-dependency-type",+ ),+ pytest.param(+ {+ "minor-and-patch": {+ "patterns": ["*"],+ "update-types": MINOR_AND_PATCH,+ },+ "rest": {"patterns": ["*"]},+ },+ id="catch-all-after-update-types",+ ),+ pytest.param(+ {+ "production": {"dependency-type": "production"},+ "rest": {"patterns": ["*"]},+ },+ id="catch-all-after-dependency-type",+ ),+ pytest.param(+ {+ "suffix": {"patterns": ["*test"]},+ "prefix": {"patterns": ["vite*"]},+ },+ id="partly-overlapping-globs",+ ),+ ],+)+def test_guard_accepts_orderings_that_hide_nothing(groups):+ assert _hidden_groups({"groups": groups}) == []+++def test_guard_flags_the_real_vitest_groups_moved_below_the_wildcards():+ """The guard bites on this repository's own groups, not only stand-ins."""+ root = next(+ entry for entry in _npm_entries() if entry.get("directory") == "/"+ )+ reversed_groups = dict(reversed(list(root["groups"].items())))++ assert _hidden_groups(root) == []+ assert {+ later for _, later, _ in _hidden_groups({"groups": reversed_groups})+ } == {"vitest", "vitest-security"}