build(agent): melter#14fd4b iteration
This commit is contained in:
parent
cea13cbdff
commit
00d1498a77
|
|
@ -15,3 +15,18 @@ class RegistryWrapper:
|
||||||
|
|
||||||
def get(self, adapter_id: str) -> Optional[Dict[str, str]]:
|
def get(self, adapter_id: str) -> Optional[Dict[str, str]]:
|
||||||
return self.graph.get_info(adapter_id)
|
return self.graph.get_info(adapter_id)
|
||||||
|
|
||||||
|
def conforms(self, adapter_id: str, required_keys: Optional[list] = None) -> bool:
|
||||||
|
"""Check whether a registered adapter advert contains the required keys.
|
||||||
|
|
||||||
|
This is a lightweight conformance helper used by registries and tests to
|
||||||
|
ensure adapters expose the minimal advertised metadata. It does not
|
||||||
|
validate types beyond presence.
|
||||||
|
"""
|
||||||
|
info = self.get(adapter_id)
|
||||||
|
if info is None:
|
||||||
|
return False
|
||||||
|
if not required_keys:
|
||||||
|
# If no keys specified, consider presence in registry as conformance
|
||||||
|
return True
|
||||||
|
return all(k in info for k in required_keys)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ if SRC not in sys.path:
|
||||||
|
|
||||||
from idea34_openpassmarket_privacy_preserving.core import LocalProblem, PerformanceSignal, PrivacyBudget, aggregate_signals
|
from idea34_openpassmarket_privacy_preserving.core import LocalProblem, PerformanceSignal, PrivacyBudget, aggregate_signals
|
||||||
from idea34_openpassmarket_privacy_preserving import PassSpec, verify_invariants
|
from idea34_openpassmarket_privacy_preserving import PassSpec, verify_invariants
|
||||||
|
from idea34_openpassmarket_privacy_preserving.registry import RegistryWrapper
|
||||||
|
|
||||||
|
|
||||||
def test_privacy_budget_consume():
|
def test_privacy_budget_consume():
|
||||||
|
|
@ -53,3 +54,25 @@ def test_verify_invariants_valid_and_invalid():
|
||||||
constraints={},
|
constraints={},
|
||||||
)
|
)
|
||||||
assert verify_invariants(lp_bad, spec, budget) is False
|
assert verify_invariants(lp_bad, spec, budget) is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_registry_register_and_conformance():
|
||||||
|
reg = RegistryWrapper()
|
||||||
|
adapter_id = "adapter_foo"
|
||||||
|
info = {
|
||||||
|
"supported_languages": "Python, C",
|
||||||
|
"contract_version": "v1",
|
||||||
|
"supported_features": "pass_spec,performance_signal",
|
||||||
|
}
|
||||||
|
# Register and retrieve
|
||||||
|
reg.register(adapter_id, info)
|
||||||
|
got = reg.get(adapter_id)
|
||||||
|
assert got is not None
|
||||||
|
assert got.get("contract_version") == "v1"
|
||||||
|
|
||||||
|
# Conformance checks
|
||||||
|
assert reg.conforms(adapter_id, required_keys=["supported_languages", "contract_version"]) is True
|
||||||
|
# Missing key should fail
|
||||||
|
assert reg.conforms(adapter_id, required_keys=["nonexistent_key"]) is False
|
||||||
|
# Non-registered adapter should return False
|
||||||
|
assert reg.conforms("no_such_adapter") is False
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue