Task 1: Simplify Capability; extend BoundEntity

- Make href Optional[str] = None for pattern capabilities
- Remove observe field (v2 architecture observes all hrefs)
- Add rt_filter, match_fn, key_fn fields to Capability
- Add entities default value tuple[()] to Capability
- Add key_override field to BoundEntity
- Update _key() to use key_override when present
- Update _make_observe_paths() to observe all unique hrefs (OBSERVE as accelerator)
- Guard _build() to skip pattern capabilities (href is None)
- Add test_bound_entity_key_override_takes_precedence test
- Update test_capability_defaults to remove observe assertion

All 61 tests passing (60 existing + 1 new).
This commit is contained in:
Marc Billow committed 2026-06-30 16:32:42 -05:00
1 parent 1a76bf6d47
commit 81d97e2fb5
6 files changed
+42 -7

No files matched your search

+2 -2
View File
@@ -27,7 +27,7 @@ def _segs(href: str) -> list[str]:
def _key(b: BoundEntity) -> str:
return f"{b.desc.key}{b.instance}"
return f"{b.key_override or b.desc.key}{b.instance}"
def _encode(cfg: dict) -> bytes:
@@ -70,7 +70,7 @@ def _make_flatten(bound: list[BoundEntity]) -> Callable[[dict], dict]:
def _make_observe_paths(bound: list[BoundEntity]) -> list[list[str]]:
seen, out = set(), []
for b in bound:
if not b.capability.observe or b.href in seen:
if b.href in seen:
continue
seen.add(b.href)
out.append(_segs(b.href))