Skip to content

Commit 17d16d5

Browse files
RobLe3claude
andcommitted
feat: expose health_label + exposure_mode on discover Node (ADR-044)
Parse the directory's ADR-044 composed health label and ADR-043 8-category exposure_mode from /v1/discover into the Node model. Both optional — None against directories predating v1.10.0 (forward-compatible). Bump 0.7.10→0.7.12 to align all three SDKs. Verified in docker (python:3.12): 20 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a3f0ddd commit 17d16d5

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "iicp-client"
7-
version = "0.7.10"
7+
version = "0.7.12"
88
description = "Official Python client SDK for the IICP protocol"
99
readme = "README.md"
1010
license = {text = "Apache-2.0"}

src/iicp_client/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ async def discover_async(
8989
region=n.get("region", ""),
9090
latency_estimate_ms=n.get("latency_estimate_ms"),
9191
reputation_score=n.get("reputation_score"),
92+
health_label=n.get("health_label"),
93+
exposure_mode=n.get("exposure_mode"),
9294
)
9395
for n in raw_nodes
9496
]

src/iicp_client/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ class Node:
110110
region: str
111111
latency_estimate_ms: int | None = None
112112
reputation_score: float | None = None
113+
# ADR-044 — composed health label (healthy/degraded/impaired/critical/offline)
114+
# and ADR-043 8-category network exposure. Both optional: present only when
115+
# the directory is on v1.10.0+; None against older directories.
116+
health_label: str | None = None
117+
exposure_mode: str | None = None
113118

114119

115120
@dataclass

tests/test_client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"score": 0.95,
3535
"available": True,
3636
"region": "eu-west",
37+
# ADR-044 / ADR-043 fields (directory v1.10.0+)
38+
"health_label": "healthy",
39+
"exposure_mode": "ipv4_public_direct",
3740
}
3841
]
3942
}
@@ -78,6 +81,20 @@ def test_discover_returns_node_list():
7881
assert len(result.nodes) == 1
7982
assert result.nodes[0].node_id == "node-abc"
8083
assert result.nodes[0].score == 0.95
84+
# ADR-044 — health_label + exposure_mode parsed from discover
85+
assert result.nodes[0].health_label == "healthy"
86+
assert result.nodes[0].exposure_mode == "ipv4_public_direct"
87+
88+
89+
@respx.mock
90+
def test_discover_health_fields_default_none_against_old_directory():
91+
# A directory predating v1.10.0 omits the fields; parsing must not break.
92+
legacy = {"nodes": [{"node_id": "n1", "endpoint": NODE, "score": 0.5, "available": True, "region": "eu"}]}
93+
respx.get(DISCOVER_URL).mock(return_value=httpx.Response(200, json=legacy))
94+
client = IicpClient(ClientConfig(directory_url=DIRECTORY))
95+
result = client.discover("urn:iicp:intent:llm:chat:v1")
96+
assert result.nodes[0].health_label is None
97+
assert result.nodes[0].exposure_mode is None
8198

8299

83100
@respx.mock

0 commit comments

Comments
 (0)