cks-runtime 0.1.2__tar.gz → 0.2.0__tar.gz
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.
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/PKG-INFO +28 -10
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/README.md +25 -8
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/config.py +5 -1
- cks_runtime-0.2.0/cks_runtime/core_api/adapter.py +154 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/core_api/interfaces.py +7 -0
- cks_runtime-0.2.0/cks_runtime/core_api/validation_result.py +53 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/diagnostics/aggregator.py +35 -17
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/diagnostics/diagnostic.py +19 -3
- cks_runtime-0.2.0/cks_runtime/explainability/explainability_manager.py +13 -0
- cks_runtime-0.2.0/cks_runtime/pipeline/execution_pipeline.py +176 -0
- cks_runtime-0.2.0/cks_runtime/runtime.py +229 -0
- cks_runtime-0.2.0/cks_runtime/session/session.py +76 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/session/session_manager.py +28 -14
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/transaction/transaction.py +25 -54
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/transaction/transaction_manager.py +25 -40
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/versioning/version.py +33 -4
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/versioning/version_manager.py +39 -17
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime.egg-info/PKG-INFO +28 -10
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime.egg-info/SOURCES.txt +8 -1
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime.egg-info/requires.txt +1 -0
- cks_runtime-0.2.0/cks_runtime.egg-info/top_level.txt +2 -0
- cks_runtime-0.2.0/cks_runtime_core/__init__.py +14 -0
- cks_runtime-0.2.0/cks_runtime_core/adapter.py +78 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/pyproject.toml +7 -15
- cks_runtime-0.2.0/tests/test_core_adapter.py +69 -0
- cks_runtime-0.1.2/cks_runtime/runtime.py +0 -85
- cks_runtime-0.1.2/cks_runtime/session/session.py +0 -72
- cks_runtime-0.1.2/cks_runtime.egg-info/top_level.txt +0 -1
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/LICENSE +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/__init__.py +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/adapters/__init__.py +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/core_api/__init__.py +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/diagnostics/__init__.py +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/explainability/__init__.py +0 -0
- {cks_runtime-0.1.2/cks_runtime/session → cks_runtime-0.2.0/cks_runtime/pipeline}/__init__.py +0 -0
- {cks_runtime-0.1.2/cks_runtime/storage → cks_runtime-0.2.0/cks_runtime/session}/__init__.py +0 -0
- {cks_runtime-0.1.2/cks_runtime/transaction → cks_runtime-0.2.0/cks_runtime/storage}/__init__.py +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/storage/exceptions.py +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/storage/memory_storage.py +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime/storage/storage.py +0 -0
- {cks_runtime-0.1.2/cks_runtime/versioning → cks_runtime-0.2.0/cks_runtime/transaction}/__init__.py +0 -0
- /cks_runtime-0.1.2/cks_runtime/explainability/explainability_manager.py → /cks_runtime-0.2.0/cks_runtime/versioning/__init__.py +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/cks_runtime.egg-info/dependency_links.txt +0 -0
- {cks_runtime-0.1.2 → cks_runtime-0.2.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cks-runtime
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Canonical Runtime for the Canonical Knowledge Structure ecosystem
|
|
5
5
|
Author: Vladyslav Hruznov
|
|
6
6
|
License: MIT
|
|
@@ -11,12 +11,13 @@ Keywords: canonical-knowledge-structure,runtime,knowledge-runtime,transactions,s
|
|
|
11
11
|
Classifier: Development Status :: 3 - Alpha
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Classifier: Topic :: Software Development :: Libraries
|
|
16
16
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
-
Requires-Python: >=3.
|
|
17
|
+
Requires-Python: >=3.12
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
+
Requires-Dist: cks-core>=1.1.1
|
|
20
21
|
Provides-Extra: dev
|
|
21
22
|
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
22
23
|
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
@@ -28,7 +29,8 @@ Dynamic: license-file
|
|
|
28
29
|
|
|
29
30
|

|
|
30
31
|

|
|
31
|
-

|
|
33
|
+

|
|
32
34
|
|
|
33
35
|
CKS Runtime is the canonical execution environment for
|
|
34
36
|
Canonical Knowledge Structures (CKS).
|
|
@@ -40,6 +42,20 @@ Runtime provides the infrastructure required to execute,
|
|
|
40
42
|
manage, version, persist and expose Canonical Knowledge Structures
|
|
41
43
|
without becoming a semantic authority itself.
|
|
42
44
|
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
# Ecosystem
|
|
48
|
+
|
|
49
|
+
CKS Runtime is part of a family of interoperable projects built on the
|
|
50
|
+
Canonical Knowledge Structure.
|
|
51
|
+
|
|
52
|
+
| Project | Description | Repository |
|
|
53
|
+
|---------|-------------|------------|
|
|
54
|
+
| **cks-core** | Semantic engine – the single source of canonical truth. | [Deus-corp/CKS](https://github.com/Deus-corp/CKS) |
|
|
55
|
+
| **cks-runtime** | Operational environment – sessions, transactions, persistence. | [Deus-corp/cks-runtime](https://github.com/Deus-corp/cks-runtime) |
|
|
56
|
+
| **cks-mcp** | MCP server – exposes CKS to LLMs via the Model Context Protocol. | [Deus-corp/cks-mcp](https://github.com/Deus-corp/cks-mcp) |
|
|
57
|
+
|
|
58
|
+
|
|
43
59
|
---
|
|
44
60
|
|
|
45
61
|
# Why Runtime?
|
|
@@ -168,6 +184,7 @@ The current Reference Runtime provides:
|
|
|
168
184
|
- Canonical Runtime API
|
|
169
185
|
- Reference Runtime Architecture
|
|
170
186
|
- Runtime Conformance Model
|
|
187
|
+
- **CKS Core Integration** (via `cks_runtime_core`)
|
|
171
188
|
|
|
172
189
|
---
|
|
173
190
|
|
|
@@ -213,7 +230,6 @@ Runtime communicates exclusively through the public CKS Core API.
|
|
|
213
230
|
From PyPI:
|
|
214
231
|
|
|
215
232
|
```bash
|
|
216
|
-
pip install cks-core
|
|
217
233
|
pip install cks-runtime
|
|
218
234
|
```
|
|
219
235
|
|
|
@@ -233,8 +249,10 @@ pip install -e .
|
|
|
233
249
|
|
|
234
250
|
```python
|
|
235
251
|
from cks_runtime import Runtime
|
|
252
|
+
from cks_runtime_core import CksCoreAdapter
|
|
236
253
|
|
|
237
|
-
|
|
254
|
+
# Create Runtime with real CKS Core attached
|
|
255
|
+
runtime = Runtime(core=CksCoreAdapter())
|
|
238
256
|
|
|
239
257
|
session = runtime.sessions.create(
|
|
240
258
|
knowledge_structure=my_structure
|
|
@@ -242,8 +260,7 @@ session = runtime.sessions.create(
|
|
|
242
260
|
|
|
243
261
|
transaction = runtime.transactions.begin(session)
|
|
244
262
|
|
|
245
|
-
# Runtime coordinates execution.
|
|
246
|
-
# CKS Core defines semantics.
|
|
263
|
+
# Runtime coordinates execution. CKS Core defines semantics.
|
|
247
264
|
```
|
|
248
265
|
|
|
249
266
|
---
|
|
@@ -286,8 +303,9 @@ Current implementation status:
|
|
|
286
303
|
| Storage Abstraction | ✅ Complete |
|
|
287
304
|
| Runtime API | ✅ Complete |
|
|
288
305
|
| Runtime Documentation | ✅ Complete |
|
|
289
|
-
|
|
|
290
|
-
|
|
|
306
|
+
| Core Integration | ✅ Complete |
|
|
307
|
+
| Reference Implementation | ✅ Complete |
|
|
308
|
+
| Adapter Infrastructure | 🚧 In Progress |
|
|
291
309
|
|
|
292
310
|
---
|
|
293
311
|
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|

|
|
7
|
-

|
|
8
|
+

|
|
8
9
|
|
|
9
10
|
CKS Runtime is the canonical execution environment for
|
|
10
11
|
Canonical Knowledge Structures (CKS).
|
|
@@ -16,6 +17,20 @@ Runtime provides the infrastructure required to execute,
|
|
|
16
17
|
manage, version, persist and expose Canonical Knowledge Structures
|
|
17
18
|
without becoming a semantic authority itself.
|
|
18
19
|
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Ecosystem
|
|
23
|
+
|
|
24
|
+
CKS Runtime is part of a family of interoperable projects built on the
|
|
25
|
+
Canonical Knowledge Structure.
|
|
26
|
+
|
|
27
|
+
| Project | Description | Repository |
|
|
28
|
+
|---------|-------------|------------|
|
|
29
|
+
| **cks-core** | Semantic engine – the single source of canonical truth. | [Deus-corp/CKS](https://github.com/Deus-corp/CKS) |
|
|
30
|
+
| **cks-runtime** | Operational environment – sessions, transactions, persistence. | [Deus-corp/cks-runtime](https://github.com/Deus-corp/cks-runtime) |
|
|
31
|
+
| **cks-mcp** | MCP server – exposes CKS to LLMs via the Model Context Protocol. | [Deus-corp/cks-mcp](https://github.com/Deus-corp/cks-mcp) |
|
|
32
|
+
|
|
33
|
+
|
|
19
34
|
---
|
|
20
35
|
|
|
21
36
|
# Why Runtime?
|
|
@@ -144,6 +159,7 @@ The current Reference Runtime provides:
|
|
|
144
159
|
- Canonical Runtime API
|
|
145
160
|
- Reference Runtime Architecture
|
|
146
161
|
- Runtime Conformance Model
|
|
162
|
+
- **CKS Core Integration** (via `cks_runtime_core`)
|
|
147
163
|
|
|
148
164
|
---
|
|
149
165
|
|
|
@@ -189,7 +205,6 @@ Runtime communicates exclusively through the public CKS Core API.
|
|
|
189
205
|
From PyPI:
|
|
190
206
|
|
|
191
207
|
```bash
|
|
192
|
-
pip install cks-core
|
|
193
208
|
pip install cks-runtime
|
|
194
209
|
```
|
|
195
210
|
|
|
@@ -209,8 +224,10 @@ pip install -e .
|
|
|
209
224
|
|
|
210
225
|
```python
|
|
211
226
|
from cks_runtime import Runtime
|
|
227
|
+
from cks_runtime_core import CksCoreAdapter
|
|
212
228
|
|
|
213
|
-
|
|
229
|
+
# Create Runtime with real CKS Core attached
|
|
230
|
+
runtime = Runtime(core=CksCoreAdapter())
|
|
214
231
|
|
|
215
232
|
session = runtime.sessions.create(
|
|
216
233
|
knowledge_structure=my_structure
|
|
@@ -218,8 +235,7 @@ session = runtime.sessions.create(
|
|
|
218
235
|
|
|
219
236
|
transaction = runtime.transactions.begin(session)
|
|
220
237
|
|
|
221
|
-
# Runtime coordinates execution.
|
|
222
|
-
# CKS Core defines semantics.
|
|
238
|
+
# Runtime coordinates execution. CKS Core defines semantics.
|
|
223
239
|
```
|
|
224
240
|
|
|
225
241
|
---
|
|
@@ -262,8 +278,9 @@ Current implementation status:
|
|
|
262
278
|
| Storage Abstraction | ✅ Complete |
|
|
263
279
|
| Runtime API | ✅ Complete |
|
|
264
280
|
| Runtime Documentation | ✅ Complete |
|
|
265
|
-
|
|
|
266
|
-
|
|
|
281
|
+
| Core Integration | ✅ Complete |
|
|
282
|
+
| Reference Implementation | ✅ Complete |
|
|
283
|
+
| Adapter Infrastructure | 🚧 In Progress |
|
|
267
284
|
|
|
268
285
|
---
|
|
269
286
|
|
|
@@ -279,4 +296,4 @@ This preserves a single semantic authority while allowing unlimited operational
|
|
|
279
296
|
|
|
280
297
|
# License
|
|
281
298
|
|
|
282
|
-
MIT
|
|
299
|
+
MIT
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Runtime Core Adapter.
|
|
3
|
+
|
|
4
|
+
The Core Adapter is the exclusive Runtime gateway
|
|
5
|
+
to CKS Core.
|
|
6
|
+
|
|
7
|
+
Runtime never communicates with CKS Core directly.
|
|
8
|
+
|
|
9
|
+
The adapter isolates Runtime from future changes
|
|
10
|
+
to the Core API.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from cks_runtime.core_api.interfaces import CoreInterface
|
|
18
|
+
from cks_runtime.core_api.validation_result import (
|
|
19
|
+
RuntimeValidationResult,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CoreAdapter:
|
|
24
|
+
"""
|
|
25
|
+
Runtime adapter over CKS Core.
|
|
26
|
+
|
|
27
|
+
Owns Runtime → Core interaction.
|
|
28
|
+
|
|
29
|
+
Never owns semantic behaviour.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
core: CoreInterface | None,
|
|
35
|
+
) -> None:
|
|
36
|
+
|
|
37
|
+
self._core = core
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def attached(self) -> bool:
|
|
41
|
+
"""
|
|
42
|
+
Whether a Core implementation is attached.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
return self._core is not None
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Validation
|
|
49
|
+
#
|
|
50
|
+
|
|
51
|
+
def validate(
|
|
52
|
+
self,
|
|
53
|
+
knowledge_structure: Any,
|
|
54
|
+
) -> RuntimeValidationResult:
|
|
55
|
+
"""
|
|
56
|
+
Delegate validation to CKS Core.
|
|
57
|
+
|
|
58
|
+
Runtime never receives Core-native
|
|
59
|
+
ValidationResult objects.
|
|
60
|
+
|
|
61
|
+
They are translated into
|
|
62
|
+
RuntimeValidationResult.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
if self._core is None:
|
|
66
|
+
|
|
67
|
+
return RuntimeValidationResult(
|
|
68
|
+
valid=True,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
result = self._core.validate(
|
|
72
|
+
knowledge_structure,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
return RuntimeValidationResult(
|
|
76
|
+
valid=getattr(
|
|
77
|
+
result,
|
|
78
|
+
"is_valid",
|
|
79
|
+
True,
|
|
80
|
+
),
|
|
81
|
+
diagnostics=tuple(
|
|
82
|
+
getattr(
|
|
83
|
+
result,
|
|
84
|
+
"diagnostics",
|
|
85
|
+
(),
|
|
86
|
+
)
|
|
87
|
+
),
|
|
88
|
+
metadata=dict(
|
|
89
|
+
getattr(
|
|
90
|
+
result,
|
|
91
|
+
"metadata",
|
|
92
|
+
{},
|
|
93
|
+
)
|
|
94
|
+
),
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
#
|
|
98
|
+
# Evolution
|
|
99
|
+
#
|
|
100
|
+
|
|
101
|
+
def evolve(
|
|
102
|
+
self,
|
|
103
|
+
knowledge_structure: Any,
|
|
104
|
+
operation: Any,
|
|
105
|
+
) -> Any:
|
|
106
|
+
"""
|
|
107
|
+
Delegate semantic evolution to CKS Core.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
if self._core is None:
|
|
111
|
+
return knowledge_structure
|
|
112
|
+
|
|
113
|
+
return self._core.evolve(
|
|
114
|
+
knowledge_structure,
|
|
115
|
+
operation,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
#
|
|
119
|
+
# Serialization
|
|
120
|
+
#
|
|
121
|
+
|
|
122
|
+
def serialize(
|
|
123
|
+
self,
|
|
124
|
+
knowledge_structure: Any,
|
|
125
|
+
) -> Any:
|
|
126
|
+
"""
|
|
127
|
+
Delegate serialization to CKS Core.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
if self._core is None:
|
|
131
|
+
return knowledge_structure
|
|
132
|
+
|
|
133
|
+
return self._core.serialize(
|
|
134
|
+
knowledge_structure,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
#
|
|
138
|
+
# Explainability
|
|
139
|
+
#
|
|
140
|
+
|
|
141
|
+
def explain(
|
|
142
|
+
self,
|
|
143
|
+
knowledge_structure: Any,
|
|
144
|
+
) -> Any:
|
|
145
|
+
"""
|
|
146
|
+
Delegate semantic explanation to CKS Core.
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
if self._core is None:
|
|
150
|
+
return None
|
|
151
|
+
|
|
152
|
+
return self._core.explain(
|
|
153
|
+
knowledge_structure,
|
|
154
|
+
)
|
|
@@ -63,6 +63,13 @@ class CoreInterface(ABC):
|
|
|
63
63
|
Runtime coordinates execution.
|
|
64
64
|
|
|
65
65
|
CKS Core defines the resulting semantic state.
|
|
66
|
+
|
|
67
|
+
Implementations should return the resulting
|
|
68
|
+
Knowledge Structure.
|
|
69
|
+
|
|
70
|
+
Runtime makes no assumptions about whether
|
|
71
|
+
evolution is performed in-place or by returning
|
|
72
|
+
a new object.
|
|
66
73
|
"""
|
|
67
74
|
|
|
68
75
|
@abstractmethod
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Runtime Validation Result.
|
|
3
|
+
|
|
4
|
+
Represents the Runtime view of semantic validation.
|
|
5
|
+
|
|
6
|
+
This object is intentionally independent from the
|
|
7
|
+
internal ValidationResult implementation of CKS Core.
|
|
8
|
+
|
|
9
|
+
The Core Adapter is responsible for translating
|
|
10
|
+
Core-specific validation objects into this Runtime model.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from dataclasses import dataclass, field
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True, slots=True)
|
|
20
|
+
class RuntimeValidationResult:
|
|
21
|
+
"""
|
|
22
|
+
Runtime representation of semantic validation.
|
|
23
|
+
|
|
24
|
+
Runtime consumes only this abstraction.
|
|
25
|
+
|
|
26
|
+
CKS Core may evolve independently.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
valid: bool
|
|
30
|
+
|
|
31
|
+
diagnostics: tuple[Any, ...] = field(
|
|
32
|
+
default_factory=tuple,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
metadata: dict[str, Any] = field(
|
|
36
|
+
default_factory=dict,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def has_diagnostics(self) -> bool:
|
|
41
|
+
"""
|
|
42
|
+
Whether validation produced diagnostics.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
return bool(self.diagnostics)
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def diagnostic_count(self) -> int:
|
|
49
|
+
"""
|
|
50
|
+
Number of diagnostics.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
return len(self.diagnostics)
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Runtime Diagnostic Aggregator.
|
|
3
3
|
|
|
4
|
-
Aggregates Runtime and Core
|
|
4
|
+
Aggregates Runtime and Core Diagnostics.
|
|
5
5
|
|
|
6
6
|
Aggregation preserves ordering and ownership.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
-
from
|
|
11
|
+
from collections.abc import Iterable
|
|
12
|
+
from collections.abc import Iterator
|
|
12
13
|
|
|
13
14
|
from .diagnostic import (
|
|
14
15
|
Diagnostic,
|
|
@@ -22,29 +23,32 @@ class DiagnosticAggregator:
|
|
|
22
23
|
|
|
23
24
|
Diagnostics remain immutable.
|
|
24
25
|
|
|
25
|
-
Aggregation never modifies
|
|
26
|
+
Aggregation never modifies
|
|
27
|
+
their semantic meaning.
|
|
26
28
|
"""
|
|
27
29
|
|
|
28
30
|
def __init__(self) -> None:
|
|
29
|
-
self._diagnostics: list[
|
|
30
|
-
|
|
31
|
+
self._diagnostics: list[
|
|
32
|
+
Diagnostic
|
|
33
|
+
] = []
|
|
31
34
|
|
|
32
35
|
def add(
|
|
33
36
|
self,
|
|
34
37
|
diagnostic: Diagnostic,
|
|
35
38
|
) -> None:
|
|
36
39
|
"""
|
|
37
|
-
Add
|
|
40
|
+
Add one Diagnostic.
|
|
38
41
|
"""
|
|
39
42
|
|
|
40
43
|
self._diagnostics.append(
|
|
41
44
|
diagnostic
|
|
42
45
|
)
|
|
43
46
|
|
|
44
|
-
|
|
45
47
|
def extend(
|
|
46
48
|
self,
|
|
47
|
-
diagnostics: Iterable[
|
|
49
|
+
diagnostics: Iterable[
|
|
50
|
+
Diagnostic
|
|
51
|
+
],
|
|
48
52
|
) -> None:
|
|
49
53
|
"""
|
|
50
54
|
Add multiple Diagnostics.
|
|
@@ -54,20 +58,21 @@ class DiagnosticAggregator:
|
|
|
54
58
|
diagnostics
|
|
55
59
|
)
|
|
56
60
|
|
|
57
|
-
|
|
58
61
|
def clear(
|
|
59
62
|
self,
|
|
60
63
|
) -> None:
|
|
61
64
|
"""
|
|
62
|
-
Remove
|
|
65
|
+
Remove every collected Diagnostic.
|
|
63
66
|
"""
|
|
64
67
|
|
|
65
68
|
self._diagnostics.clear()
|
|
66
69
|
|
|
67
|
-
|
|
68
70
|
def all(
|
|
69
71
|
self,
|
|
70
|
-
) -> tuple[
|
|
72
|
+
) -> tuple[
|
|
73
|
+
Diagnostic,
|
|
74
|
+
...
|
|
75
|
+
]:
|
|
71
76
|
"""
|
|
72
77
|
Return an immutable snapshot.
|
|
73
78
|
"""
|
|
@@ -76,20 +81,33 @@ class DiagnosticAggregator:
|
|
|
76
81
|
self._diagnostics
|
|
77
82
|
)
|
|
78
83
|
|
|
84
|
+
@property
|
|
85
|
+
def empty(
|
|
86
|
+
self,
|
|
87
|
+
) -> bool:
|
|
88
|
+
"""
|
|
89
|
+
Whether no Diagnostics exist.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
return not self._diagnostics
|
|
79
93
|
|
|
80
94
|
def count(
|
|
81
95
|
self,
|
|
82
96
|
) -> int:
|
|
97
|
+
"""
|
|
98
|
+
Number of collected Diagnostics.
|
|
99
|
+
"""
|
|
100
|
+
|
|
83
101
|
return len(
|
|
84
102
|
self._diagnostics
|
|
85
103
|
)
|
|
86
104
|
|
|
87
|
-
|
|
88
105
|
def has_errors(
|
|
89
106
|
self,
|
|
90
107
|
) -> bool:
|
|
91
108
|
"""
|
|
92
|
-
True if
|
|
109
|
+
True if at least one Diagnostic
|
|
110
|
+
has ERROR severity.
|
|
93
111
|
"""
|
|
94
112
|
|
|
95
113
|
return any(
|
|
@@ -98,7 +116,6 @@ class DiagnosticAggregator:
|
|
|
98
116
|
for diagnostic in self._diagnostics
|
|
99
117
|
)
|
|
100
118
|
|
|
101
|
-
|
|
102
119
|
def __len__(
|
|
103
120
|
self,
|
|
104
121
|
) -> int:
|
|
@@ -106,10 +123,11 @@ class DiagnosticAggregator:
|
|
|
106
123
|
self._diagnostics
|
|
107
124
|
)
|
|
108
125
|
|
|
109
|
-
|
|
110
126
|
def __iter__(
|
|
111
127
|
self,
|
|
112
|
-
)
|
|
128
|
+
) -> Iterator[
|
|
129
|
+
Diagnostic
|
|
130
|
+
]:
|
|
113
131
|
return iter(
|
|
114
132
|
self._diagnostics
|
|
115
133
|
)
|
|
@@ -3,6 +3,8 @@ Runtime Diagnostic model.
|
|
|
3
3
|
|
|
4
4
|
Runtime Diagnostics describe operational observations.
|
|
5
5
|
|
|
6
|
+
Diagnostics are immutable.
|
|
7
|
+
|
|
6
8
|
They never modify Runtime state and never redefine
|
|
7
9
|
CKS Core semantics.
|
|
8
10
|
"""
|
|
@@ -44,7 +46,8 @@ class Diagnostic:
|
|
|
44
46
|
|
|
45
47
|
- Core Diagnostics belong to CKS Core;
|
|
46
48
|
- Runtime Diagnostics belong to Runtime;
|
|
47
|
-
- Runtime preserves
|
|
49
|
+
- Runtime preserves Diagnostics without
|
|
50
|
+
modifying them.
|
|
48
51
|
"""
|
|
49
52
|
|
|
50
53
|
message: str
|
|
@@ -64,5 +67,18 @@ class Diagnostic:
|
|
|
64
67
|
)
|
|
65
68
|
|
|
66
69
|
created_at: datetime = field(
|
|
67
|
-
default_factory=lambda: datetime.now(
|
|
68
|
-
|
|
70
|
+
default_factory=lambda: datetime.now(
|
|
71
|
+
UTC
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def __str__(self) -> str:
|
|
76
|
+
"""
|
|
77
|
+
Human-readable representation.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
f"[{self.severity.value.upper()}] "
|
|
82
|
+
f"{self.source.value}: "
|
|
83
|
+
f"{self.message}"
|
|
84
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class ExplainabilityManager:
|
|
2
|
+
"""
|
|
3
|
+
Coordinates Runtime explainability.
|
|
4
|
+
|
|
5
|
+
Runtime delegates semantic explanations
|
|
6
|
+
to the attached Core.
|
|
7
|
+
|
|
8
|
+
Future versions may combine Runtime
|
|
9
|
+
diagnostics and Core explanations into
|
|
10
|
+
a unified explanation model.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
pass
|