story: DGR-041 Register native Shard capabilities without redesigning Meshnet
This commit is contained in:
@@ -190,6 +190,9 @@ class CapabilityState:
|
||||
# ("dark"/"certified"), so the network map answers "why is this exact node
|
||||
# not routing" without a second query. None when no identity was presented.
|
||||
certification: str | None = None
|
||||
memory_capacity_bytes: int | None = None
|
||||
kv_capacity_tokens: int | None = None
|
||||
max_concurrent_sessions: int | None = None
|
||||
|
||||
@property
|
||||
def proven(self) -> bool:
|
||||
@@ -233,6 +236,9 @@ class CapabilityState:
|
||||
"runtime_recipe_digest": self.runtime_recipe_digest,
|
||||
"shard_binding_digest": self.shard_binding_digest,
|
||||
"certification": self.certification,
|
||||
"memory_capacity_bytes": self.memory_capacity_bytes,
|
||||
"kv_capacity_tokens": self.kv_capacity_tokens,
|
||||
"max_concurrent_sessions": self.max_concurrent_sessions,
|
||||
}
|
||||
|
||||
|
||||
@@ -491,6 +497,10 @@ def _parse_report(doc: Mapping[str, Any]) -> dict:
|
||||
if isinstance(schema_version, bool) or not isinstance(schema_version, int):
|
||||
raise _ReportError("'schema_version' must be an integer")
|
||||
|
||||
capacity = doc.get("capacity")
|
||||
if capacity is not None:
|
||||
capacity = _object(capacity, "capacity")
|
||||
|
||||
return {
|
||||
"model_id": _text(model.get("model_id"), "model.model_id"),
|
||||
"shard_start": _index(shard.get("start"), "shard.start"),
|
||||
@@ -508,6 +518,18 @@ def _parse_report(doc: Mapping[str, Any]) -> dict:
|
||||
"validated_at": float(validated_at),
|
||||
"schema_version": schema_version,
|
||||
"diagnostics": _diagnostics(doc.get("diagnostics")),
|
||||
"memory_capacity_bytes": _optional_positive_int(
|
||||
None if capacity is None else capacity.get("memory_capacity_bytes"),
|
||||
"capacity.memory_capacity_bytes",
|
||||
),
|
||||
"kv_capacity_tokens": _optional_positive_int(
|
||||
None if capacity is None else capacity.get("kv_capacity_tokens"),
|
||||
"capacity.kv_capacity_tokens",
|
||||
),
|
||||
"max_concurrent_sessions": _optional_positive_int(
|
||||
None if capacity is None else capacity.get("max_concurrent_sessions"),
|
||||
"capacity.max_concurrent_sessions",
|
||||
),
|
||||
"_status": _text(doc.get("status"), "status"),
|
||||
}
|
||||
|
||||
@@ -536,6 +558,14 @@ def _index(value: Any, field_name: str) -> int:
|
||||
return value
|
||||
|
||||
|
||||
def _optional_positive_int(value: Any, field_name: str) -> int | None:
|
||||
if value is None:
|
||||
return None
|
||||
if isinstance(value, bool) or not isinstance(value, int) or value < 1:
|
||||
raise _ReportError(f"{field_name!r} must be a positive integer")
|
||||
return value
|
||||
|
||||
|
||||
def _maybe_int(value: Any) -> int | None:
|
||||
if isinstance(value, bool) or not isinstance(value, int):
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user