From a4ca201d741997cab3696102e94419bf6bb7f8e9 Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Fri, 6 Nov 2026 22:13:21 +0000 Subject: [PATCH] fix(overview-metrics): non-sticky native count switch, client timeout, count scope - Native counting is disabled for a server only when it really lacks the endpoint (404/405/501, not implemented); timeouts and other transient errors fail just that count. A disable expires after 300s. - count_metadata_elements / count_relationships_between_elements (sync and async) defaulted to a hardcoded 30s timeout, ignoring the client's time_out; they now default to None and use the client's. - count_elements, count_relationships and the Overview count helpers take scope=None|'viewer'|'repository' mapping to native push_down. A repository-scope count never falls back to the viewer-scoped find. Signed-off-by: Dan Wolfson --- pyegeria/omvs/metadata_expert.py | 24 +-- pyegeria/view/overview_metrics.py | 163 +++++++++++++++++---- tests/micro-tests/test_overview_metrics.py | 100 +++++++++++++ 3 files changed, 249 insertions(+), 38 deletions(-) diff --git a/pyegeria/omvs/metadata_expert.py b/pyegeria/omvs/metadata_expert.py index af410e92..a651cee6 100644 --- a/pyegeria/omvs/metadata_expert.py +++ b/pyegeria/omvs/metadata_expert.py @@ -3823,7 +3823,7 @@ async def _async_count_metadata_elements( self, body: dict, push_down: Optional[bool] = None, - timeout: int = default_timeout, + timeout: Optional[int] = None, **kwargs, ) -> int: """Return the number of metadata elements that match the supplied criteria. @@ -3849,8 +3849,8 @@ async def _async_count_metadata_elements( reading every one of them server-side). `None` omits the query parameter, and the server default applies: `false` on Egeria main since the 2026-10-18 fixes, `true` on older servers. - timeout: int, default = default_timeout - - http request timeout for this request + timeout: int, optional + - http request timeout for this request; None (default) uses the client's own time_out Returns ------- @@ -3890,7 +3890,7 @@ def count_metadata_elements( self, body: dict, push_down: Optional[bool] = None, - timeout: int = default_timeout, + timeout: Optional[int] = None, **kwargs, ) -> int: """Return the number of metadata elements that match the supplied criteria. @@ -3906,8 +3906,8 @@ def count_metadata_elements( push_down: bool, optional, default = None - ISSUE-38 (PY-18): see `_async_count_metadata_elements` for the full explanation. `None` omits the query parameter (server default). - timeout: int, default = default_timeout - - http request timeout for this request + timeout: int, optional + - http request timeout for this request; None (default) uses the client's own time_out Returns ------- @@ -4137,7 +4137,7 @@ async def _async_count_relationships_between_elements( self, body: dict, push_down: Optional[bool] = None, - timeout: int = default_timeout, + timeout: Optional[int] = None, **kwargs, ) -> int: """Return the number of relationships that match the requested conditions. @@ -4166,8 +4166,8 @@ async def _async_count_relationships_between_elements( server-side). `None` omits the query parameter, and the server default applies: `false` on Egeria main since the 2026-10-18 fixes, `true` on older servers. - timeout: int, default = default_timeout - - http request timeout for this request + timeout: int, optional + - http request timeout for this request; None (default) uses the client's own time_out Returns ------- @@ -4208,7 +4208,7 @@ def count_relationships_between_elements( self, body: dict, push_down: Optional[bool] = None, - timeout: int = default_timeout, + timeout: Optional[int] = None, **kwargs, ) -> int: """Return the number of relationships that match the requested conditions. @@ -4226,8 +4226,8 @@ def count_relationships_between_elements( - ISSUE-38 (PY-18): see `_async_count_relationships_between_elements` for the full explanation. `None` omits the query parameter (server default). - timeout: int, default = default_timeout - - http request timeout for this request + timeout: int, optional + - http request timeout for this request; None (default) uses the client's own time_out Returns ------- diff --git a/pyegeria/view/overview_metrics.py b/pyegeria/view/overview_metrics.py index 1c9f81b7..33a8aa7e 100644 --- a/pyegeria/view/overview_metrics.py +++ b/pyegeria/view/overview_metrics.py @@ -25,10 +25,16 @@ """ import inspect +import time from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple from loguru import logger +from pyegeria.core._exceptions import ( + PyegeriaConnectionException, + PyegeriaNotFoundException, + PyegeriaTimeoutException, +) from pyegeria.core._globals import max_paging_size __all__ = [ @@ -115,22 +121,67 @@ def growth_label(d, span_s: int) -> str: _ELEMENT_COUNT_CANDIDATES = ("count_metadata_elements", "get_metadata_element_count") _REL_COUNT_CANDIDATES = ("count_relationships_between_elements", "count_relationships") _count_caps: Dict[str, Optional[str]] = {} -_native_server_ok: Dict[str, bool] = {} +_native_server_ok: Dict[str, float] = {} # server key -> monotonic time native was found unsupported def _server_key(client) -> str: return f"{getattr(client, 'platform_url', '')}|{getattr(client, 'view_server', '')}" +# How long a "this server has no native counts" verdict is trusted before the +# next count tries native again (a server upgraded to support it is picked up +# without a process restart). +NATIVE_DISABLE_TTL_S = 300.0 + +_UNSUPPORTED_MARKERS = ("not implemented", "not supported", "unsupported", "no such method", + "no static resource", "not found") + + +def _native_unsupported(exc: Exception) -> bool: + """True only when `exc` says the server lacks the native count endpoint + (404/405/501 or an equivalent message). A timeout, a connection error or + any other transient failure is NOT evidence of that: it fails only the one + count (which then uses the len(find) fallback) and leaves native enabled.""" + if isinstance(exc, (PyegeriaTimeoutException, PyegeriaConnectionException)): + return False + if isinstance(exc, PyegeriaNotFoundException): + return True + code = getattr(exc, "http_status_code", None) or getattr(exc, "related_http_code", None) + if code in (404, 405, 501): + return True + ai = getattr(exc, "additional_info", None) + if isinstance(ai, dict) and ai.get("relatedHTTPCode") in (404, 405, 501): + return True + if isinstance(exc, (AttributeError, NotImplementedError)): + return True + msg = str(exc).lower() + return any(m in msg for m in _UNSUPPORTED_MARKERS) + + def _native_disabled(client) -> bool: - return _native_server_ok.get(_server_key(client)) is False + key = _server_key(client) + since = _native_server_ok.get(key) + if since is None: + return False + if time.monotonic() - since > NATIVE_DISABLE_TTL_S: + _native_server_ok.pop(key, None) # expired: try native again + return False + return True def _disable_native(client, exc) -> None: + """Record that native counting failed. Only a 'server lacks it' error + disables native for the server (until NATIVE_DISABLE_TTL_S); anything else + is transient and only that one count falls back.""" + if not _native_unsupported(exc): + logger.info(f"overview_metrics count seam: native count failed once for " + f"{_server_key(client)} ({exc}) -- this count falls back; native stays enabled") + return if not _native_disabled(client): logger.info(f"overview_metrics count seam: native count not supported by " - f"{_server_key(client)} -- using len(find/get) fallback ({exc})") - _native_server_ok[_server_key(client)] = False + f"{_server_key(client)} -- using len(find/get) fallback for " + f"{NATIVE_DISABLE_TTL_S:.0f}s ({exc})") + _native_server_ok[_server_key(client)] = time.monotonic() def _native_count_method(client, candidates: Sequence[str], cache_key: str) -> Optional[str]: @@ -192,25 +243,57 @@ def _find_or_none(mgr, body: dict, page_size: int = DEFAULT_CAP) -> Optional[lis return None -def _element_count(mgr, body: dict, as_of: Optional[str] = None, strict: bool = False) -> Optional[int]: +SCOPE_VIEWER = "viewer" +SCOPE_REPOSITORY = "repository" + + +def _push_down(scope: Optional[str]) -> Optional[bool]: + """Map a count scope to the native `push_down` argument: "viewer" -> False + (server counts only what the caller may see), "repository" -> True (a raw + repository COUNT: fast, but it also counts elements the caller cannot see), + None -> None (omit it; the server default applies). Raises ValueError for + any other value -- a programming error, not a runtime condition.""" + if scope is None: + return None + if scope == SCOPE_VIEWER: + return False + if scope == SCOPE_REPOSITORY: + return True + raise ValueError(f"scope must be None, {SCOPE_VIEWER!r} or {SCOPE_REPOSITORY!r}; got {scope!r}") + + +def _element_count(mgr, body: dict, as_of: Optional[str] = None, strict: bool = False, + scope: Optional[str] = None) -> Optional[int]: """Count elements matching a FindRequestBody -- native when available, else len(find_metadata_elements(...)). + scope="repository": only a native push-down count can answer. The + len(find) fallback is always viewer-scoped, so it is NOT used -- the result + is None (strict) or 0 (non-strict, the historical failure value) instead of + a viewer number masquerading as a repository one. + strict=False: 0 when the fallback query fails (the historical behaviour). strict=True: None when the count is not known -- the fallback query failed, or it returned a full page (DEFAULT_CAP), which is only a lower bound. """ + push_down = _push_down(scope) + kw = {} if push_down is None else {"push_down": push_down} b = dict(body) if as_of: b["asOfTime"] = as_of name = _native_count_method(mgr, _ELEMENT_COUNT_CANDIDATES, "elem:" + type(mgr).__name__) if name and not _native_disabled(mgr): try: - c = _as_count(getattr(mgr, name)(b)) + c = _as_count(getattr(mgr, name)(b, **kw)) if c is not None: return c except Exception as exc: # noqa: BLE001 -- old server: mark unsupported, fall back _disable_native(mgr, exc) + if scope == SCOPE_REPOSITORY: + logger.warning(f"overview_metrics: repository-scope count of " + f"{body.get('metadataElementTypeName') or 'elements'!r} not measured -- " + f"native count unavailable or failed (the find fallback is viewer-scoped)") + return None if strict else 0 if not strict: return len(_find(mgr, b)) found = _find_or_none(mgr, b) @@ -231,6 +314,7 @@ def count_elements( as_of: Optional[str] = None, classifications: Optional[Sequence[str]] = None, strict: bool = False, + scope: Optional[str] = None, ) -> Optional[int]: """ Count ACTIVE elements, optionally of a given type and/or matching ANY of @@ -250,6 +334,11 @@ def count_elements( single call's worth (some connectors mishandle 2+ ANY conditions) strict : when True, return None if the query failed, or if the fallback count hit DEFAULT_CAP (a lower bound, not a total) + scope : None (server default), "viewer" (push_down=False: only what the + caller may see) or "repository" (push_down=True: whole-repository raw + count, fast, includes elements the caller cannot see). The len(find) + fallback always answers in viewer scope, so with scope="repository" it + is never used: a failed native count is None (strict) or 0 (non-strict). Returns ------- @@ -263,7 +352,7 @@ def count_elements( "class": "SearchClassifications", "matchCriteria": "ANY", "conditions": [{"name": n} for n in classifications], } - return _element_count(mgr, body, as_of, strict) + return _element_count(mgr, body, as_of, strict, scope) def count_elements_by_property( @@ -273,6 +362,7 @@ def count_elements_by_property( property_value: str, as_of: Optional[str] = None, strict: bool = False, + scope: Optional[str] = None, ) -> Optional[int]: """ Count ACTIVE elements of a given type whose named string property equals @@ -291,6 +381,7 @@ def count_elements_by_property( property_value : the exact string value to match as_of : ISO-8601 asOfTime for a point-in-time count (None = now) strict : as for count_elements -- None instead of 0 when not measured + scope : as for count_elements (None | "viewer" | "repository") Returns ------- @@ -310,10 +401,11 @@ def count_elements_by_property( }], }, } - return _element_count(mgr, body, as_of, strict) + return _element_count(mgr, body, as_of, strict, scope) -def count_relationships(ce, relationship_type: str, as_of: Optional[str] = None, expert=None) -> Optional[int]: +def count_relationships(ce, relationship_type: str, as_of: Optional[str] = None, expert=None, + scope: Optional[str] = None) -> Optional[int]: """ Count relationships of a type, optionally as of a past time. @@ -332,11 +424,19 @@ def count_relationships(ce, relationship_type: str, as_of: Optional[str] = None, relationship_type : the relationship type name to count as_of : ISO-8601 asOfTime for a point-in-time count (None = now) expert : optional MetadataExpert to enable the native fast-path + scope : None (default: today's behaviour), "viewer" (native push_down=False) + or "repository" (native push_down=True). Only the native path takes a + scope; the get_relationships path is always viewer-scoped, so with + scope="repository" it is never used -- a missing `expert`, an + unsupported server or a failed native call gives None, not a viewer + number. Returns ------- Optional[int] -- None on total failure (never raises) """ + push_down = _push_down(scope) + kw = {} if push_down is None else {"push_down": push_down} if expert is not None and not _native_disabled(expert): name = _native_count_method(expert, _REL_COUNT_CANDIDATES, "rel:" + type(expert).__name__) if name: @@ -345,11 +445,15 @@ def count_relationships(ce, relationship_type: str, as_of: Optional[str] = None, if as_of: body["asOfTime"] = as_of try: - c = _as_count(getattr(expert, name)(body)) + c = _as_count(getattr(expert, name)(body, **kw)) if c is not None: return c except Exception as exc: # noqa: BLE001 _disable_native(expert, exc) + if scope == SCOPE_REPOSITORY: + logger.warning(f"overview_metrics: repository-scope count of {relationship_type!r} not measured -- " + f"native count unavailable or failed (get_relationships is viewer-scoped)") + return None try: body = {"class": "ResultsRequestBody", "asOfTime": as_of} if as_of else None return len(_json_list(ce.get_relationships( @@ -361,17 +465,17 @@ def count_relationships(ce, relationship_type: str, as_of: Optional[str] = None, def counts_by_type(mgr, type_map: Sequence[Tuple[str, str]], as_of: Optional[str] = None, - strict: bool = False) -> List[Dict[str, Any]]: + strict: bool = False, scope: Optional[str] = None) -> List[Dict[str, Any]]: """ Per-type counts for a set of (label, type_name) pairs -- e.g. the assets- by-type composition breakdown. Unknown/wrong types just yield 0 rather than failing the whole call. With strict=True, a count that could not be - measured is None (see count_elements). + measured is None (see count_elements). `scope` is passed to count_elements. Returns a list of {"label": ..., "type": ..., "count": ...} dicts, in the order given. """ - return [{"label": label, "type": type_name, "count": count_elements(mgr, type_name, as_of, strict=strict)} + return [{"label": label, "type": type_name, "count": count_elements(mgr, type_name, as_of, strict=strict, scope=scope)} for label, type_name in type_map] @@ -559,7 +663,7 @@ def ownership_coverage(mgr, as_of: Optional[str] = None) -> Dict[str, Any]: } -def business_value_signals(mgr, as_of: Optional[str] = None) -> Dict[str, Any]: +def business_value_signals(mgr, as_of: Optional[str] = None, scope: Optional[str] = None) -> Dict[str, Any]: """ Real signals behind the Overview dashboard's four "Business Value" tiles (NEXT-9) -- replaces the four previously-synthetic narrative numbers @@ -594,6 +698,9 @@ def business_value_signals(mgr, as_of: Optional[str] = None) -> Dict[str, Any]: demo dataset, confirmed live -- so a rating average is honestly omitted rather than faked). + `scope` applies to the duplicate count only; the Asset-derived fields come + from a find and stay viewer-scoped. + Any field whose query failed is None (unmeasured), never 0: assetTotal/ assetCapped/confidentialCount/describedCount when the Asset find fails, duplicateCount when its (strict) count fails. @@ -621,7 +728,7 @@ def business_value_signals(mgr, as_of: Optional[str] = None) -> Dict[str, Any]: if isinstance(desc, str) and desc.strip(): described += 1 - duplicate = count_elements(mgr, None, as_of, classifications=["ConsolidatedDuplicate"], strict=True) + duplicate = count_elements(mgr, None, as_of, classifications=["ConsolidatedDuplicate"], strict=True, scope=scope) return { "assetTotal": len(assets) if assets is not None else None, @@ -1094,7 +1201,7 @@ def _update_time(el: dict): return None -def people_counts(mgr, as_of: Optional[str] = None, strict: bool = False) -> Dict[str, Optional[int]]: +def people_counts(mgr, as_of: Optional[str] = None, strict: bool = False, scope: Optional[str] = None) -> Dict[str, Optional[int]]: """ Person / Team / Organization / ITProfile / Community counts via native element counts (sub-second where an older find-and-bucket approach would @@ -1108,11 +1215,11 @@ def people_counts(mgr, as_of: Optional[str] = None, strict: bool = False) -> Dic could not be measured is None (see count_elements). """ return { - "persons": count_elements(mgr, "Person", as_of, strict=strict), - "teams": count_elements(mgr, "Team", as_of, strict=strict), - "organizations": count_elements(mgr, "Organization", as_of, strict=strict), - "itProfiles": count_elements(mgr, "ITProfile", as_of, strict=strict), - "communities": count_elements(mgr, "Community", as_of, strict=strict), + "persons": count_elements(mgr, "Person", as_of, strict=strict, scope=scope), + "teams": count_elements(mgr, "Team", as_of, strict=strict, scope=scope), + "organizations": count_elements(mgr, "Organization", as_of, strict=strict, scope=scope), + "itProfiles": count_elements(mgr, "ITProfile", as_of, strict=strict, scope=scope), + "communities": count_elements(mgr, "Community", as_of, strict=strict, scope=scope), } @@ -1125,24 +1232,28 @@ def people_counts(mgr, as_of: Optional[str] = None, strict: bool = False) -> Dic ) -def feedback_summary(ce, as_of: Optional[str] = None) -> Dict[str, Any]: +def feedback_summary(ce, as_of: Optional[str] = None, scope: Optional[str] = None, expert=None) -> Dict[str, Any]: """ Crowd-sourced feedback tally -- ratings/comments/likes/tags/note-logs (Collaboration OMAS relationship counts). Often sparse in demo data, but real. + `scope` (and the MetadataExpert it needs, `expert`) are passed to + count_relationships; scope="repository" without `expert` yields None for + every type. + A type whose count failed is None in `byType`; `total` is None unless every type was measured (a partial sum would read as "less feedback"). Returns {"byType": {ratings, comments, likes, tags, noteLogs: int|None}, "total": int|None}. """ - by_type = {key: count_relationships(ce, rel, as_of) for rel, key in _FEEDBACK_RELATIONSHIP_TYPES} + by_type = {key: count_relationships(ce, rel, as_of, expert=expert, scope=scope) for rel, key in _FEEDBACK_RELATIONSHIP_TYPES} measured = all(v is not None for v in by_type.values()) return {"byType": by_type, "total": sum(by_type.values()) if measured else None} -def usage_context_counts(mgr, as_of: Optional[str] = None, strict: bool = False) -> Dict[str, Optional[int]]: +def usage_context_counts(mgr, as_of: Optional[str] = None, strict: bool = False, scope: Optional[str] = None) -> Dict[str, Optional[int]]: """ InformationSupplyChain and SolutionBlueprint counts -- what puts assets in a *usage context* ("this store feeds the Clinical Trial supply @@ -1152,8 +1263,8 @@ def usage_context_counts(mgr, as_of: Optional[str] = None, strict: bool = False) strict=True, a count that could not be measured is None (see count_elements). """ return { - "informationSupplyChains": count_elements(mgr, "InformationSupplyChain", as_of, strict=strict), - "blueprints": count_elements(mgr, "SolutionBlueprint", as_of, strict=strict), + "informationSupplyChains": count_elements(mgr, "InformationSupplyChain", as_of, strict=strict, scope=scope), + "blueprints": count_elements(mgr, "SolutionBlueprint", as_of, strict=strict, scope=scope), } diff --git a/tests/micro-tests/test_overview_metrics.py b/tests/micro-tests/test_overview_metrics.py index 4513cddf..0d50bc61 100644 --- a/tests/micro-tests/test_overview_metrics.py +++ b/tests/micro-tests/test_overview_metrics.py @@ -742,3 +742,103 @@ def test_governed_coverage_and_business_value_none_on_failed_find(): b = om.business_value_signals(mgr) assert b["assetTotal"] is None and b["confidentialCount"] is None assert b["describedCount"] is None and b["duplicateCount"] is None + + +# ── sticky native-count switch ─────────────────────────────────────────── + +def test_timeout_does_not_disable_native_counting(): + from pyegeria.core._exceptions import PyegeriaTimeoutException + mgr = _mgr(count_metadata_elements=MagicMock(side_effect=[PyegeriaTimeoutException(), 987])) + mgr.find_metadata_elements.return_value = [{}] * 3 + assert om.count_elements(mgr, "Asset") == 3 # that one count falls back + assert not om._native_disabled(mgr) + assert om.count_elements(mgr, "GlossaryTerm", strict=True) == 987 # native still used + + +def test_transient_generic_error_does_not_disable_native(): + mgr = _mgr(count_metadata_elements=MagicMock(side_effect=[RuntimeError("boom"), 5])) + mgr.find_metadata_elements.return_value = [] + om.count_elements(mgr, "Asset") + assert not om._native_disabled(mgr) + assert om.count_elements(mgr, "Asset") == 5 + + +def test_not_supported_error_disables_native(): + from pyegeria.core._exceptions import PyegeriaNotFoundException + resp = MagicMock(status_code=404, url="https://x/count", text="") + resp.json.return_value = {} + for exc in (PyegeriaNotFoundException(resp), RuntimeError("Operation not implemented")): + om._native_server_ok.clear(); om._count_caps.clear() + mgr = _mgr(count_metadata_elements=MagicMock(side_effect=exc)) + mgr.find_metadata_elements.return_value = [{}] * 2 + assert om.count_elements(mgr, "Asset") == 2 + assert om._native_disabled(mgr) + om.count_elements(mgr, "Asset") + assert mgr.count_metadata_elements.call_count == 1 # not retried + + +def test_native_disable_expires(monkeypatch): + mgr = _mgr(count_metadata_elements=MagicMock(return_value=9)) + om._native_server_ok[om._server_key(mgr)] = om.time.monotonic() - om.NATIVE_DISABLE_TTL_S - 1 + assert not om._native_disabled(mgr) + assert om.count_elements(mgr, "Asset") == 9 + + +# ── count scope -> native push_down ────────────────────────────────────── + +@pytest.mark.parametrize("scope,expected", [("viewer", False), ("repository", True)]) +def test_scope_maps_to_push_down(scope, expected): + mgr = _mgr(count_metadata_elements=MagicMock(return_value=11)) + assert om.count_elements(mgr, "Asset", scope=scope) == 11 + assert mgr.count_metadata_elements.call_args.kwargs == {"push_down": expected} + + +def test_scope_none_omits_push_down(): + mgr = _mgr(count_metadata_elements=MagicMock(return_value=11)) + om.count_elements(mgr, "Asset") + assert mgr.count_metadata_elements.call_args.kwargs == {} + + +def test_invalid_scope_raises(): + with pytest.raises(ValueError): + om.count_elements(_mgr(), "Asset", scope="everyone") + + +def test_repository_scope_failure_strict_is_none_not_find_result(): + mgr = _mgr(count_metadata_elements=MagicMock(side_effect=RuntimeError("boom"))) + mgr.find_metadata_elements.return_value = [{}] * 43 # viewer-scope answer + assert om.count_elements(mgr, "Asset", strict=True, scope="repository") is None + assert om.count_elements(mgr, "Asset", scope="repository") == 0 + mgr.find_metadata_elements.assert_not_called() + + +def test_repository_scope_without_native_method_is_none(): + mgr = _mgr() + mgr.find_metadata_elements.return_value = [{}] * 3 + assert om.count_elements(mgr, "Asset", strict=True, scope="repository") is None + assert om.count_elements(mgr, "Asset", strict=True, scope="viewer") == 3 # viewer may fall back + + +def test_scope_threads_through_helpers(): + mgr = _mgr(count_metadata_elements=MagicMock(return_value=2)) + om.counts_by_type(mgr, [("A", "Asset")], scope="repository") + om.people_counts(mgr, scope="repository") + om.usage_context_counts(mgr, scope="repository") + om.count_elements_by_property(mgr, "DigitalProduct", "deploymentStatus", "ACTIVE", scope="repository") + calls = mgr.count_metadata_elements.call_args_list + assert len(calls) == 1 + 5 + 2 + 1 + assert all(c.kwargs == {"push_down": True} for c in calls) + + +def test_count_relationships_scope(): + expert = MagicMock(spec=["count_relationships_between_elements", "platform_url", "view_server"]) + expert.platform_url, expert.view_server = "u", "v" + expert.count_relationships_between_elements.return_value = 4 + ce = MagicMock() + ce.get_relationships.return_value = [{}] * 9 + assert om.count_relationships(ce, "License", expert=expert, scope="repository") == 4 + assert expert.count_relationships_between_elements.call_args.kwargs == {"push_down": True} + # no expert: repository scope cannot be answered by the viewer-scoped path + assert om.count_relationships(ce, "License", scope="repository") is None + assert om.count_relationships(ce, "License") == 9 + assert om.feedback_summary(ce, scope="repository")["total"] is None