refactor: key capabilities on href instead of rt

OCF rt is a schema category shared by many unrelated resources.
The stable unique resource address is the href. Update Capability,
discovery, common capabilities, tests, and plan accordingly.
This commit is contained in:
Marc Billow committed 2026-06-30 16:32:37 -05:00
1 parent bdae3cc82d
commit 0499c702d7
6 files changed
+62 -66

No files matched your search

+13 -15
View File
@@ -1,8 +1,8 @@
"""Runtime discovery: device resources -> bound entities.
A device advertises a set of OCF resources, each carrying one or more `rt`
values. For every rt present in the registry, emit the capability's entities
bound to that resource href. Unknown rt is a coverage gap, logged and skipped.
A device advertises a set of OCF resources keyed by href. For every href
present in the registry, emit the capability's entities bound to that resource.
Unknown hrefs are a coverage gap, logged at debug and skipped.
"""
from __future__ import annotations
@@ -30,21 +30,19 @@ def instance_suffix(href: str) -> str:
def discover(resources: dict[str, dict],
registry: dict[str, Capability],
registry: dict[str, 'Capability'],
log: Optional[Callable[[str], None]] = None) -> list[BoundEntity]:
out: list[BoundEntity] = []
for href, rep in resources.items():
if not isinstance(rep, dict):
continue
rts = rep.get('rt') or []
for rt in rts:
cap = registry.get(rt)
if cap is None:
if log is not None:
log(f"unknown capability {rt} at {href}")
continue
inst = instance_suffix(href)
for desc in cap.entities:
out.append(BoundEntity(href=href, capability=cap,
desc=desc, instance=inst))
cap = registry.get(href)
if cap is None:
if log is not None:
log(f"unknown resource {href}")
continue
inst = instance_suffix(href)
for desc in cap.entities:
out.append(BoundEntity(href=href, capability=cap,
desc=desc, instance=inst))
return out