system-runtime-spec 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- system_runtime/__init__.py +22 -0
- system_runtime/_version.py +86 -0
- system_runtime/clock.py +35 -0
- system_runtime/components.py +103 -0
- system_runtime/filesystem.py +168 -0
- system_runtime/health.py +186 -0
- system_runtime/models/__init__.py +20 -0
- system_runtime/models/_sidex.py +274 -0
- system_runtime/models/component.py +134 -0
- system_runtime/models/filesystem.py +39 -0
- system_runtime/models/health.py +172 -0
- system_runtime/models/py.typed +0 -0
- system_runtime/models/value.py +105 -0
- system_runtime/py.typed +0 -0
- system_runtime/snapshot.py +24 -0
- system_runtime/threshold.py +150 -0
- system_runtime_spec-0.1.0.dist-info/METADATA +186 -0
- system_runtime_spec-0.1.0.dist-info/RECORD +21 -0
- system_runtime_spec-0.1.0.dist-info/WHEEL +4 -0
- system_runtime_spec-0.1.0.dist-info/licenses/LICENSE-APACHE +202 -0
- system_runtime_spec-0.1.0.dist-info/licenses/LICENSE-MIT +21 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# DO NOT EDIT! This file is autogenerated.
|
|
2
|
+
|
|
3
|
+
"""Model parsing, serialization, and built-in types in Sidex's JSON representation.
|
|
4
|
+
|
|
5
|
+
64-bit integers beyond a magnitude of 2**53 - 1 are decimal strings in JSON,
|
|
6
|
+
because JavaScript cannot represent them exactly as numbers. Non-finite floats
|
|
7
|
+
are the strings ``"NaN"``, ``"+Infinity"``, and ``"-Infinity"``. Bytes are
|
|
8
|
+
Base64 strings with padding. Decoding also accepts decimal strings for all
|
|
9
|
+
64-bit integers.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import base64
|
|
15
|
+
import datetime
|
|
16
|
+
import math
|
|
17
|
+
import re
|
|
18
|
+
import uuid
|
|
19
|
+
from typing import Annotated, Any, ClassVar, cast
|
|
20
|
+
|
|
21
|
+
import pydantic
|
|
22
|
+
import pydantic_core
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def inline(**kwargs: Any) -> Any:
|
|
26
|
+
"""Declare a field that shares its surrounding object's entries.
|
|
27
|
+
|
|
28
|
+
Return Any like pydantic.Field so this can initialize typed model fields.
|
|
29
|
+
"""
|
|
30
|
+
field: pydantic.fields.FieldInfo = pydantic.Field(**kwargs)
|
|
31
|
+
field.metadata.append(Inline)
|
|
32
|
+
return field
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Inline:
|
|
36
|
+
"""Mark fields that read from and write into their surrounding object."""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class Model(pydantic.BaseModel):
|
|
40
|
+
"""Apply Sidex field representations to records and variant case models."""
|
|
41
|
+
|
|
42
|
+
_sidex_optional: ClassVar[tuple[tuple[str, str], ...]] = ()
|
|
43
|
+
_sidex_inline: ClassVar[tuple[tuple[str, str, str], ...]] = ()
|
|
44
|
+
|
|
45
|
+
@classmethod
|
|
46
|
+
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
|
|
47
|
+
super().__pydantic_init_subclass__(**kwargs)
|
|
48
|
+
# Only optional Sidex fields have a None default.
|
|
49
|
+
cls._sidex_optional = tuple(
|
|
50
|
+
(name, field.serialization_alias or name)
|
|
51
|
+
for name, field in cls.model_fields.items()
|
|
52
|
+
if field.default is None
|
|
53
|
+
)
|
|
54
|
+
# Sidex generates only string validation aliases.
|
|
55
|
+
cls._sidex_inline = tuple(
|
|
56
|
+
(
|
|
57
|
+
name,
|
|
58
|
+
cast(str, field.validation_alias or name),
|
|
59
|
+
field.serialization_alias or name,
|
|
60
|
+
)
|
|
61
|
+
for name, field in cls.model_fields.items()
|
|
62
|
+
if Inline in field.metadata
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
@pydantic.model_validator(mode="before")
|
|
66
|
+
@classmethod
|
|
67
|
+
def _sidex_read(cls, value: object) -> object:
|
|
68
|
+
if not isinstance(value, dict) or not cls._sidex_inline:
|
|
69
|
+
return value
|
|
70
|
+
result = value.copy()
|
|
71
|
+
for name, alias, _ in cls._sidex_inline:
|
|
72
|
+
# Native model instances support construction and payload() methods;
|
|
73
|
+
# wire objects always decode inline fields from the surrounding map.
|
|
74
|
+
native = value.get(name)
|
|
75
|
+
result[alias] = native if isinstance(native, pydantic.BaseModel) else value
|
|
76
|
+
return result
|
|
77
|
+
|
|
78
|
+
@pydantic.model_serializer(mode="wrap")
|
|
79
|
+
def _sidex_serialize(
|
|
80
|
+
self,
|
|
81
|
+
handler: pydantic.SerializerFunctionWrapHandler,
|
|
82
|
+
info: pydantic.SerializationInfo,
|
|
83
|
+
) -> dict[str, Any]:
|
|
84
|
+
result: dict[str, Any] = handler(self)
|
|
85
|
+
by_alias = info.by_alias
|
|
86
|
+
if by_alias is None:
|
|
87
|
+
by_alias = self.model_config.get("serialize_by_alias", False)
|
|
88
|
+
for name, alias in self._sidex_optional:
|
|
89
|
+
if getattr(self, name) is None:
|
|
90
|
+
result.pop(alias if by_alias else name, None)
|
|
91
|
+
if not self._sidex_inline:
|
|
92
|
+
return result
|
|
93
|
+
inline = {alias if by_alias else name for name, _, alias in self._sidex_inline}
|
|
94
|
+
flattened: dict[str, Any] = {}
|
|
95
|
+
for key, value in result.items():
|
|
96
|
+
if key in inline:
|
|
97
|
+
flattened.update(value)
|
|
98
|
+
else:
|
|
99
|
+
flattened[key] = value
|
|
100
|
+
return flattened
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# Serializers raise `PydanticSerializationUnexpectedValue` for values of other
|
|
104
|
+
# types, so serializing unions tries the next member.
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
_MAX_SAFE_INTEGER = 2**53 - 1
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _int64(value: object) -> object:
|
|
111
|
+
if isinstance(value, str):
|
|
112
|
+
if not re.fullmatch("-?[0-9]+", value):
|
|
113
|
+
raise ValueError("expected an integer or a decimal string")
|
|
114
|
+
return int(value)
|
|
115
|
+
return value
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _encode_int64(value: object) -> int | str:
|
|
119
|
+
if not isinstance(value, int) or isinstance(value, bool):
|
|
120
|
+
raise pydantic_core.PydanticSerializationUnexpectedValue("expected an integer")
|
|
121
|
+
return value if abs(value) <= _MAX_SAFE_INTEGER else str(value)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _float(value: object) -> float | str:
|
|
125
|
+
if not isinstance(value, float):
|
|
126
|
+
raise pydantic_core.PydanticSerializationUnexpectedValue("expected a float")
|
|
127
|
+
if math.isnan(value):
|
|
128
|
+
return "NaN"
|
|
129
|
+
if math.isinf(value):
|
|
130
|
+
return "+Infinity" if value > 0 else "-Infinity"
|
|
131
|
+
return value
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
_NON_FINITE = {
|
|
135
|
+
"NaN": math.nan,
|
|
136
|
+
"+Infinity": math.inf,
|
|
137
|
+
"Infinity": math.inf,
|
|
138
|
+
"-Infinity": -math.inf,
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _parse_float(value: object) -> object:
|
|
143
|
+
# Only non-finite floats are strings, so that strings select string cases
|
|
144
|
+
# of implicitly tagged variants.
|
|
145
|
+
if isinstance(value, bool):
|
|
146
|
+
# Pydantic reports ValueError as a validation failure; TypeError escapes validation.
|
|
147
|
+
raise ValueError("expected a number") # noqa: TRY004
|
|
148
|
+
if isinstance(value, str):
|
|
149
|
+
if value not in _NON_FINITE:
|
|
150
|
+
raise ValueError(
|
|
151
|
+
"expected a number or one of `NaN`, `+Infinity`, and `-Infinity`"
|
|
152
|
+
)
|
|
153
|
+
return _NON_FINITE[value]
|
|
154
|
+
return value
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _decode_bytes(value: object) -> object:
|
|
158
|
+
if isinstance(value, str):
|
|
159
|
+
return base64.b64decode(value + "=" * (-len(value) % 4), validate=True)
|
|
160
|
+
return value
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _encode_bytes(value: object) -> str:
|
|
164
|
+
if not isinstance(value, bytes):
|
|
165
|
+
raise pydantic_core.PydanticSerializationUnexpectedValue("expected bytes")
|
|
166
|
+
return base64.b64encode(value).decode("ascii")
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# Booleans and integers are strict, like in other languages: `1` is not a
|
|
170
|
+
# boolean, `true` is not an integer, and `300` is not a `u8`. Only 64-bit
|
|
171
|
+
# integers accept decimal strings.
|
|
172
|
+
Bool = Annotated[bool, pydantic.Strict()]
|
|
173
|
+
|
|
174
|
+
I8 = Annotated[int, pydantic.Strict(), pydantic.Field(ge=-(2**7), le=2**7 - 1)]
|
|
175
|
+
|
|
176
|
+
I16 = Annotated[int, pydantic.Strict(), pydantic.Field(ge=-(2**15), le=2**15 - 1)]
|
|
177
|
+
|
|
178
|
+
I32 = Annotated[int, pydantic.Strict(), pydantic.Field(ge=-(2**31), le=2**31 - 1)]
|
|
179
|
+
|
|
180
|
+
U8 = Annotated[int, pydantic.Strict(), pydantic.Field(ge=0, le=2**8 - 1)]
|
|
181
|
+
|
|
182
|
+
U16 = Annotated[int, pydantic.Strict(), pydantic.Field(ge=0, le=2**16 - 1)]
|
|
183
|
+
|
|
184
|
+
U32 = Annotated[int, pydantic.Strict(), pydantic.Field(ge=0, le=2**32 - 1)]
|
|
185
|
+
|
|
186
|
+
Idx = Annotated[int, pydantic.Strict(), pydantic.Field(ge=0)]
|
|
187
|
+
|
|
188
|
+
I64 = Annotated[
|
|
189
|
+
int,
|
|
190
|
+
pydantic.BeforeValidator(_int64),
|
|
191
|
+
pydantic.Strict(),
|
|
192
|
+
pydantic.Field(ge=-(2**63), le=2**63 - 1),
|
|
193
|
+
pydantic.PlainSerializer(_encode_int64, return_type=int | str, when_used="json"),
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
U64 = Annotated[
|
|
197
|
+
int,
|
|
198
|
+
pydantic.BeforeValidator(_int64),
|
|
199
|
+
pydantic.Strict(),
|
|
200
|
+
pydantic.Field(ge=0, le=2**64 - 1),
|
|
201
|
+
pydantic.PlainSerializer(_encode_int64, return_type=int | str, when_used="json"),
|
|
202
|
+
]
|
|
203
|
+
|
|
204
|
+
F32 = Annotated[
|
|
205
|
+
float,
|
|
206
|
+
pydantic.BeforeValidator(_parse_float),
|
|
207
|
+
pydantic.PlainSerializer(_float, when_used="json"),
|
|
208
|
+
]
|
|
209
|
+
|
|
210
|
+
F64 = Annotated[
|
|
211
|
+
float,
|
|
212
|
+
pydantic.BeforeValidator(_parse_float),
|
|
213
|
+
pydantic.PlainSerializer(_float, when_used="json"),
|
|
214
|
+
]
|
|
215
|
+
|
|
216
|
+
Bytes = Annotated[
|
|
217
|
+
bytes,
|
|
218
|
+
pydantic.BeforeValidator(_decode_bytes),
|
|
219
|
+
pydantic.PlainSerializer(_encode_bytes, return_type=str, when_used="json"),
|
|
220
|
+
]
|
|
221
|
+
|
|
222
|
+
Uuid = uuid.UUID
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class _Timestamp(datetime.datetime):
|
|
226
|
+
"""A datetime that retains the sub-microsecond digits of its wire value."""
|
|
227
|
+
|
|
228
|
+
_sidex_nanosecond: int
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def _parse_timestamp(
|
|
232
|
+
value: object, handler: pydantic.ValidatorFunctionWrapHandler
|
|
233
|
+
) -> datetime.datetime:
|
|
234
|
+
parsed: datetime.datetime = handler(value)
|
|
235
|
+
if not isinstance(value, str):
|
|
236
|
+
return parsed
|
|
237
|
+
fraction = re.search(r"[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}\.([0-9]+)", value)
|
|
238
|
+
if fraction and len(fraction[1]) > 9:
|
|
239
|
+
raise ValueError("timestamp precision exceeds nanoseconds")
|
|
240
|
+
nanoseconds = int(fraction[1].ljust(9, "0")) if fraction else 0
|
|
241
|
+
result = _Timestamp(
|
|
242
|
+
parsed.year,
|
|
243
|
+
parsed.month,
|
|
244
|
+
parsed.day,
|
|
245
|
+
parsed.hour,
|
|
246
|
+
parsed.minute,
|
|
247
|
+
parsed.second,
|
|
248
|
+
parsed.microsecond,
|
|
249
|
+
tzinfo=parsed.tzinfo,
|
|
250
|
+
fold=parsed.fold,
|
|
251
|
+
)
|
|
252
|
+
result._sidex_nanosecond = nanoseconds
|
|
253
|
+
return result
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def _encode_timestamp(value: object) -> str:
|
|
257
|
+
if not isinstance(value, datetime.datetime):
|
|
258
|
+
raise pydantic_core.PydanticSerializationUnexpectedValue("expected a datetime")
|
|
259
|
+
nanoseconds = getattr(value, "_sidex_nanosecond", value.microsecond * 1000)
|
|
260
|
+
utc = value.astimezone(datetime.timezone.utc)
|
|
261
|
+
text = utc.isoformat(timespec="seconds").removesuffix("+00:00")
|
|
262
|
+
fraction = f"{nanoseconds:09d}".rstrip("0")
|
|
263
|
+
return text + ("." + fraction if fraction else "") + "Z"
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
Timestamp = Annotated[
|
|
267
|
+
pydantic.AwareDatetime,
|
|
268
|
+
pydantic.WrapValidator(_parse_timestamp),
|
|
269
|
+
pydantic.PlainSerializer(_encode_timestamp, return_type=str, when_used="json"),
|
|
270
|
+
]
|
|
271
|
+
|
|
272
|
+
Date = datetime.date
|
|
273
|
+
|
|
274
|
+
Json = pydantic.JsonValue
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# DO NOT EDIT! This file is autogenerated.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Literal, TYPE_CHECKING, Union # noqa: F401
|
|
6
|
+
|
|
7
|
+
import pydantic # noqa: F401
|
|
8
|
+
import pydantic_core # noqa: F401
|
|
9
|
+
|
|
10
|
+
from . import _sidex # noqa: F401
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ComponentDeclaration(_sidex.Model):
|
|
14
|
+
"""A participant in a system composition."""
|
|
15
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
16
|
+
|
|
17
|
+
id: str = pydantic.Field(description="Unique component ID within the composition.")
|
|
18
|
+
origin: str | None = pydantic.Field(default=None, description="Ownership group for replacement or removal, matched exactly.")
|
|
19
|
+
version: str | None = pydantic.Field(default=None, description="Component version, also provided as an implicit capability.")
|
|
20
|
+
provides: list[CapabilityDeclaration] | None = pydantic.Field(default=None, description="Explicit capabilities.")
|
|
21
|
+
claims: list[ClaimDeclaration] | None = pydantic.Field(default=None, description="Exclusive resource ownership.")
|
|
22
|
+
requires: list[CapabilitySelectorDeclaration] | None = pydantic.Field(default=None, description="Selectors that must each match at least one capability.")
|
|
23
|
+
conflicts: list[CapabilitySelectorDeclaration] | None = pydantic.Field(default=None, description="Selectors that must not match any capability, including this component's.")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ClaimDeclaration(_sidex.Model):
|
|
27
|
+
"""An exclusive resource key."""
|
|
28
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
29
|
+
|
|
30
|
+
id: str = pydantic.Field(description="Resource ID.")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class CapabilityDeclaration(_sidex.Model):
|
|
34
|
+
"""A fact supplied by a component."""
|
|
35
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
36
|
+
|
|
37
|
+
id: str = pydantic.Field(description="Capability ID.")
|
|
38
|
+
version: str | None = pydantic.Field(default=None, description="Version, mutually exclusive with value.")
|
|
39
|
+
value: str | None = pydantic.Field(default=None, description="Exact string value, mutually exclusive with version.")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class CapabilitySelectorDeclaration(_sidex.Model):
|
|
43
|
+
"""A selector over provided capabilities."""
|
|
44
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
45
|
+
|
|
46
|
+
id: str = pydantic.Field(description="Capability ID.")
|
|
47
|
+
version: str | None = pydantic.Field(default=None, description="Version requirement, mutually exclusive with value.")
|
|
48
|
+
value: str | None = pydantic.Field(default=None, description="Exact value requirement, mutually exclusive with version.")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class CompatibilityReport(_sidex.Model):
|
|
52
|
+
"""Result of evaluating the complete component set."""
|
|
53
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
54
|
+
|
|
55
|
+
consistent: _sidex.Bool = pydantic.Field(description="Whether all constraints are satisfied.")
|
|
56
|
+
problems: list[CompatibilityProblem] = pydantic.Field(description="Violated constraints in deterministic evaluation order.")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class ComponentIdProblem(_sidex.Model):
|
|
60
|
+
"""Duplicate component ID."""
|
|
61
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
62
|
+
|
|
63
|
+
id: str = pydantic.Field(description="Component ID.")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class ClaimProblem(_sidex.Model):
|
|
67
|
+
"""Duplicate exclusive ownership."""
|
|
68
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
69
|
+
|
|
70
|
+
id: str = pydantic.Field(description="Resource ID.")
|
|
71
|
+
components: list[str] = pydantic.Field(description="IDs of owning components.")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class SelectorProblem(_sidex.Model):
|
|
75
|
+
"""Unsatisfied selector."""
|
|
76
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
77
|
+
|
|
78
|
+
component: str = pydantic.Field(description="Requiring component.")
|
|
79
|
+
selector: CapabilitySelectorDeclaration = pydantic.Field(description="Unsatisfied requirement.")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class ConflictProblem(_sidex.Model):
|
|
83
|
+
"""A matching conflict."""
|
|
84
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
85
|
+
|
|
86
|
+
component: str = pydantic.Field(description="Component declaring the conflict.")
|
|
87
|
+
selector: CapabilitySelectorDeclaration = pydantic.Field(description="Matching selector.")
|
|
88
|
+
provider: str = pydantic.Field(description="Component providing the capability.")
|
|
89
|
+
capability: CapabilityDeclaration = pydantic.Field(description="Matching capability.")
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class CompatibilityProblem_DuplicateComponent(_sidex.Model):
|
|
93
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
94
|
+
|
|
95
|
+
problem: Literal["duplicateComponent"] = "duplicateComponent"
|
|
96
|
+
id: str = pydantic.Field(description="Component ID.")
|
|
97
|
+
def payload(self) -> "ComponentIdProblem":
|
|
98
|
+
return ComponentIdProblem(id=self.id)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class CompatibilityProblem_DuplicateClaim(_sidex.Model):
|
|
102
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
103
|
+
|
|
104
|
+
problem: Literal["duplicateClaim"] = "duplicateClaim"
|
|
105
|
+
id: str = pydantic.Field(description="Resource ID.")
|
|
106
|
+
components: list[str] = pydantic.Field(description="IDs of owning components.")
|
|
107
|
+
def payload(self) -> "ClaimProblem":
|
|
108
|
+
return ClaimProblem(id=self.id, components=self.components)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class CompatibilityProblem_UnsatisfiedRequirement(_sidex.Model):
|
|
112
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
113
|
+
|
|
114
|
+
problem: Literal["unsatisfiedRequirement"] = "unsatisfiedRequirement"
|
|
115
|
+
component: str = pydantic.Field(description="Requiring component.")
|
|
116
|
+
selector: CapabilitySelectorDeclaration = pydantic.Field(description="Unsatisfied requirement.")
|
|
117
|
+
def payload(self) -> "SelectorProblem":
|
|
118
|
+
return SelectorProblem(component=self.component, selector=self.selector)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class CompatibilityProblem_Conflict(_sidex.Model):
|
|
122
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
123
|
+
|
|
124
|
+
problem: Literal["conflict"] = "conflict"
|
|
125
|
+
component: str = pydantic.Field(description="Component declaring the conflict.")
|
|
126
|
+
selector: CapabilitySelectorDeclaration = pydantic.Field(description="Matching selector.")
|
|
127
|
+
provider: str = pydantic.Field(description="Component providing the capability.")
|
|
128
|
+
capability: CapabilityDeclaration = pydantic.Field(description="Matching capability.")
|
|
129
|
+
def payload(self) -> "ConflictProblem":
|
|
130
|
+
return ConflictProblem(component=self.component, selector=self.selector, provider=self.provider, capability=self.capability)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# A violated composition constraint.
|
|
134
|
+
type CompatibilityProblem = Annotated[CompatibilityProblem_DuplicateComponent | CompatibilityProblem_DuplicateClaim | CompatibilityProblem_UnsatisfiedRequirement | CompatibilityProblem_Conflict, pydantic.Discriminator("problem")]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# DO NOT EDIT! This file is autogenerated.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Literal, TYPE_CHECKING, Union # noqa: F401
|
|
6
|
+
|
|
7
|
+
import pydantic # noqa: F401
|
|
8
|
+
import pydantic_core # noqa: F401
|
|
9
|
+
|
|
10
|
+
from . import _sidex # noqa: F401
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from . import component as _schema_component # noqa: F401
|
|
14
|
+
from . import health as _schema_health # noqa: F401
|
|
15
|
+
from . import value as _schema_value # noqa: F401
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class DirectoryConfig(_sidex.Model):
|
|
19
|
+
"""Additional absolute directory paths supplied by packages or administrators.
|
|
20
|
+
Whole `*` path segments match real directories in lexical order on each load.
|
|
21
|
+
Explicit path segments may follow symlinks; `..` and partial wildcards are invalid."""
|
|
22
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
23
|
+
|
|
24
|
+
components: list[str] | None = pydantic.Field(default=None, description="Additional component declaration directories.")
|
|
25
|
+
health_nodes: list[str] | None = pydantic.Field(default=None, description="Additional health definition directories.", validation_alias="healthNodes", serialization_alias="healthNodes")
|
|
26
|
+
health_statuses: list[str] | None = pydantic.Field(default=None, description="Additional health status directories.", validation_alias="healthStatuses", serialization_alias="healthStatuses")
|
|
27
|
+
values: list[str] | None = pydantic.Field(default=None, description="Additional value definition directories.")
|
|
28
|
+
value_observations: list[str] | None = pydantic.Field(default=None, description="Additional value observation directories.", validation_alias="valueObservations", serialization_alias="valueObservations")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class RuntimeSnapshot(_sidex.Model):
|
|
32
|
+
"""Complete collection loaded from a filesystem or supplied directly."""
|
|
33
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
34
|
+
|
|
35
|
+
components: list[_schema_component.ComponentDeclaration] = pydantic.Field(description="Component declarations.")
|
|
36
|
+
health_nodes: list[_schema_health.HealthNode] = pydantic.Field(description="Health definitions.", validation_alias="healthNodes", serialization_alias="healthNodes")
|
|
37
|
+
health_statuses: list[_schema_health.HealthStatus] = pydantic.Field(description="Published health status records.", validation_alias="healthStatuses", serialization_alias="healthStatuses")
|
|
38
|
+
values: list[_schema_value.ValueDefinition] | None = pydantic.Field(default=None, description="Numeric value definitions.")
|
|
39
|
+
value_observations: list[_schema_value.ValueObservation] | None = pydantic.Field(default=None, description="Published value observations.", validation_alias="valueObservations", serialization_alias="valueObservations")
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# DO NOT EDIT! This file is autogenerated.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Literal, TYPE_CHECKING, Union # noqa: F401
|
|
6
|
+
|
|
7
|
+
import pydantic # noqa: F401
|
|
8
|
+
import pydantic_core # noqa: F401
|
|
9
|
+
|
|
10
|
+
from . import _sidex # noqa: F401
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from . import value as _schema_value # noqa: F401
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Identifier of a health graph node, serialized as a string.
|
|
17
|
+
type HealthNodeId = str
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class HealthNode(_sidex.Model):
|
|
21
|
+
"""A health check or function in a directed acyclic graph."""
|
|
22
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
23
|
+
|
|
24
|
+
id: HealthNodeId = pydantic.Field(description="Unique health node ID.")
|
|
25
|
+
origin: str | None = pydantic.Field(default=None, description="Ownership group for replacement or removal, matched exactly.")
|
|
26
|
+
label: str | None = pydantic.Field(default=None, description="Human-readable label.")
|
|
27
|
+
components: list[str] | None = pydantic.Field(default=None, description="Related component IDs; these associations do not imply health dependencies.")
|
|
28
|
+
rule: HealthRule = pydantic.Field(description="How this node's health is determined.")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ObservationRule(_sidex.Model):
|
|
32
|
+
"""Constraints on externally supplied observations."""
|
|
33
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
34
|
+
|
|
35
|
+
max_age_ms: _sidex.U32 | None = pydantic.Field(default=None, description="Optional consumer limit on status age, in milliseconds.", validation_alias="maxAgeMs", serialization_alias="maxAgeMs")
|
|
36
|
+
expected_tag: str | None = pydantic.Field(default=None, description="Optional tag that published status records must match exactly.", validation_alias="expectedTag", serialization_alias="expectedTag")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ThresholdRule(_sidex.Model):
|
|
40
|
+
"""Desired and minimum ranges for one runtime value."""
|
|
41
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
42
|
+
|
|
43
|
+
value: _schema_value.ValueId = pydantic.Field(description="Value definition supplying the unit, identity, and freshness constraints.")
|
|
44
|
+
healthy: _schema_value.ValueRange = pydantic.Field(description="Desired range; must be a subset of the usable range.")
|
|
45
|
+
usable: _schema_value.ValueRange = pydantic.Field(description="Minimum range for usability.")
|
|
46
|
+
max_age_ms: _sidex.U32 | None = pydantic.Field(default=None, description="Optional consumer limit on observation age, in milliseconds; must be positive.", validation_alias="maxAgeMs", serialization_alias="maxAgeMs")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class AggregationRule(_sidex.Model):
|
|
50
|
+
"""Minimum and desired health targets."""
|
|
51
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
52
|
+
|
|
53
|
+
inputs: list[HealthNodeId] = pydantic.Field(description="Distinct input node IDs.")
|
|
54
|
+
required: _sidex.U32 = pydantic.Field(description="Minimum input count with confirmed usability required.")
|
|
55
|
+
healthy: _sidex.U32 = pydantic.Field(description="Desired healthy input count; required <= healthy <= inputs length.")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class HealthStatus(_sidex.Model):
|
|
59
|
+
"""Reported status of one observed node within a boot."""
|
|
60
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
61
|
+
|
|
62
|
+
id: HealthNodeId = pydantic.Field(description="Observed node ID.")
|
|
63
|
+
origin: str | None = pydantic.Field(default=None, description="Ownership group; must match the node's origin when one is specified.")
|
|
64
|
+
state: HealthState = pydantic.Field(description="Reported health.")
|
|
65
|
+
boot_id: str = pydantic.Field(description="Boot identifier defining the observation clock domain.", validation_alias="bootId", serialization_alias="bootId")
|
|
66
|
+
observed_at_ms: _sidex.U64 = pydantic.Field(description="Milliseconds on the boot-time clock when health was observed.", validation_alias="observedAtMs", serialization_alias="observedAtMs")
|
|
67
|
+
max_age_ms: _sidex.U32 = pydantic.Field(description="Finite positive validity duration in milliseconds.", validation_alias="maxAgeMs", serialization_alias="maxAgeMs")
|
|
68
|
+
tag: str | None = pydantic.Field(default=None, description="Opaque label identifying the check configuration or instance.")
|
|
69
|
+
message: str | None = pydantic.Field(default=None, description="Explanation supplied by the observer.")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class HealthContext(_sidex.Model):
|
|
73
|
+
"""Clock context supplied by a consumer."""
|
|
74
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
75
|
+
|
|
76
|
+
boot_id: str = pydantic.Field(description="Current boot identifier.", validation_alias="bootId", serialization_alias="bootId")
|
|
77
|
+
now_ms: _sidex.U64 = pydantic.Field(description="Current boot-time clock value in milliseconds.", validation_alias="nowMs", serialization_alias="nowMs")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class HealthClockSample(_sidex.Model):
|
|
81
|
+
"""Paired wall-clock and boot-time sample from the system being observed."""
|
|
82
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
83
|
+
|
|
84
|
+
context: HealthContext = pydantic.Field(description="Boot identifier and boot-time milliseconds at sampling.")
|
|
85
|
+
timestamp: _sidex.Timestamp = pydantic.Field(description="Wall-clock timestamp at the same instant, serialized as an RFC 3339 string.")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class HealthSnapshot(_sidex.Model):
|
|
89
|
+
"""Transport view of a health graph and the evidence used to evaluate it."""
|
|
90
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
91
|
+
|
|
92
|
+
clock: HealthClockSample = pydantic.Field(description="Clock correlation sampled after collecting the records.")
|
|
93
|
+
nodes: list[HealthNode] = pydantic.Field(description="Health definitions, including their origins.")
|
|
94
|
+
statuses: list[HealthStatus] = pydantic.Field(description="Original status records; observation times and validity are preserved.")
|
|
95
|
+
values: list[_schema_value.ValueDefinition] | None = pydantic.Field(default=None, description="Value definitions used by threshold nodes or displayed independently.")
|
|
96
|
+
value_observations: list[_schema_value.ValueObservation] | None = pydantic.Field(default=None, description="Original measurements; observation times and validity are preserved.", validation_alias="valueObservations", serialization_alias="valueObservations")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class HealthReport(_sidex.Model):
|
|
100
|
+
"""Evaluated graph, in declaration order."""
|
|
101
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
102
|
+
|
|
103
|
+
nodes: list[HealthNodeResult] = pydantic.Field(description="Evaluated nodes.")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class HealthNodeResult(_sidex.Model):
|
|
107
|
+
"""Evaluated state and evidence for a node."""
|
|
108
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
109
|
+
|
|
110
|
+
id: HealthNodeId = pydantic.Field(description="Node ID.")
|
|
111
|
+
origin: str | None = pydantic.Field(default=None, description="Origin of the evaluated node.")
|
|
112
|
+
state: HealthState = pydantic.Field(description="Evaluated health.")
|
|
113
|
+
usable: _sidex.Bool | None = pydantic.Field(default=None, description="Whether minimum criteria are met; absent when usability is unknown.")
|
|
114
|
+
inputs: list[HealthNodeId] = pydantic.Field(description="Direct dependencies explaining an aggregate result.")
|
|
115
|
+
message: str | None = pydantic.Field(default=None, description="Observation message or freshness explanation.")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class HealthRule_Observed(_sidex.Model):
|
|
119
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
120
|
+
|
|
121
|
+
rule: Literal["observed"] = "observed"
|
|
122
|
+
max_age_ms: _sidex.U32 | None = pydantic.Field(default=None, description="Optional consumer limit on status age, in milliseconds.", validation_alias="maxAgeMs", serialization_alias="maxAgeMs")
|
|
123
|
+
expected_tag: str | None = pydantic.Field(default=None, description="Optional tag that published status records must match exactly.", validation_alias="expectedTag", serialization_alias="expectedTag")
|
|
124
|
+
def payload(self) -> "ObservationRule":
|
|
125
|
+
return ObservationRule(max_age_ms=self.max_age_ms, expected_tag=self.expected_tag)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class HealthRule_Threshold(_sidex.Model):
|
|
129
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
130
|
+
|
|
131
|
+
rule: Literal["threshold"] = "threshold"
|
|
132
|
+
value: _schema_value.ValueId = pydantic.Field(description="Value definition supplying the unit, identity, and freshness constraints.")
|
|
133
|
+
healthy: _schema_value.ValueRange = pydantic.Field(description="Desired range; must be a subset of the usable range.")
|
|
134
|
+
usable: _schema_value.ValueRange = pydantic.Field(description="Minimum range for usability.")
|
|
135
|
+
max_age_ms: _sidex.U32 | None = pydantic.Field(default=None, description="Optional consumer limit on observation age, in milliseconds; must be positive.", validation_alias="maxAgeMs", serialization_alias="maxAgeMs")
|
|
136
|
+
def payload(self) -> "ThresholdRule":
|
|
137
|
+
return ThresholdRule(value=self.value, healthy=self.healthy, usable=self.usable, max_age_ms=self.max_age_ms)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class HealthRule_Aggregate(_sidex.Model):
|
|
141
|
+
model_config = pydantic.ConfigDict(populate_by_name=True, serialize_by_alias=True, defer_build=True)
|
|
142
|
+
|
|
143
|
+
rule: Literal["aggregate"] = "aggregate"
|
|
144
|
+
inputs: list[HealthNodeId] = pydantic.Field(description="Distinct input node IDs.")
|
|
145
|
+
required: _sidex.U32 = pydantic.Field(description="Minimum input count with confirmed usability required.")
|
|
146
|
+
healthy: _sidex.U32 = pydantic.Field(description="Desired healthy input count; required <= healthy <= inputs length.")
|
|
147
|
+
def payload(self) -> "AggregationRule":
|
|
148
|
+
return AggregationRule(inputs=self.inputs, required=self.required, healthy=self.healthy)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# Definition of an observed, threshold, or aggregate node.
|
|
152
|
+
type HealthRule = Annotated[HealthRule_Observed | HealthRule_Threshold | HealthRule_Aggregate, pydantic.Discriminator("rule")]
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class HealthState_Healthy(pydantic.RootModel[Literal["healthy"]]):
|
|
156
|
+
pass
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class HealthState_Degraded(pydantic.RootModel[Literal["degraded"]]):
|
|
160
|
+
pass
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class HealthState_Unhealthy(pydantic.RootModel[Literal["unhealthy"]]):
|
|
164
|
+
pass
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class HealthState_Unknown(pydantic.RootModel[Literal["unknown"]]):
|
|
168
|
+
pass
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
# Health relative to a node's declared expectations.
|
|
172
|
+
type HealthState = HealthState_Healthy | HealthState_Degraded | HealthState_Unhealthy | HealthState_Unknown
|
|
File without changes
|