onec-interactive-runtime-core 0.1.19__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.
Files changed (87) hide show
  1. onec_interactive_runtime_core-0.1.19.dist-info/METADATA +12 -0
  2. onec_interactive_runtime_core-0.1.19.dist-info/RECORD +87 -0
  3. onec_interactive_runtime_core-0.1.19.dist-info/WHEEL +4 -0
  4. onec_interactive_runtime_core-0.1.19.dist-info/licenses/COPYRIGHT +9 -0
  5. onec_interactive_runtime_core-0.1.19.dist-info/licenses/LICENSE +232 -0
  6. onec_interactive_runtime_core-0.1.19.dist-info/licenses/THIRD_PARTY_NOTICES.txt +32 -0
  7. onec_runtime/AGENTS.md +7 -0
  8. onec_runtime/__init__.py +3 -0
  9. onec_runtime/artifacts.py +59 -0
  10. onec_runtime/bootstrap.py +310 -0
  11. onec_runtime/breakpoint_workspace.py +249 -0
  12. onec_runtime/bsl/__init__.py +139 -0
  13. onec_runtime/bsl/diagnostics.py +1046 -0
  14. onec_runtime/bsl/full_ast_worker_projection.py +522 -0
  15. onec_runtime/bsl/generated_semantic_parser.py +6322 -0
  16. onec_runtime/bsl/lexer.py +164 -0
  17. onec_runtime/bsl/module_catalog.py +420 -0
  18. onec_runtime/bsl/module_delta.py +1079 -0
  19. onec_runtime/bsl/module_universe.py +1877 -0
  20. onec_runtime/bsl/notebook_cells.py +232 -0
  21. onec_runtime/bsl/notebook_method_globals.py +74 -0
  22. onec_runtime/bsl/notebook_methods.py +175 -0
  23. onec_runtime/bsl/parser_artifact_identity.py +119 -0
  24. onec_runtime/bsl/parser_target.py +388 -0
  25. onec_runtime/bsl/preprocessor.py +16 -0
  26. onec_runtime/bsl/semantic_lowering.py +1539 -0
  27. onec_runtime/bsl/source_maps.py +2411 -0
  28. onec_runtime/bsl/worker_dependency_resolver.py +289 -0
  29. onec_runtime/bsl/worker_preprocessor.py +247 -0
  30. onec_runtime/bsl/worker_projection_model.py +137 -0
  31. onec_runtime/bsl/worker_reload_source_map.py +1697 -0
  32. onec_runtime/capture.py +113 -0
  33. onec_runtime/capture_source.py +453 -0
  34. onec_runtime/compact_table.py +376 -0
  35. onec_runtime/compact_table_backend.py +500 -0
  36. onec_runtime/config.py +198 -0
  37. onec_runtime/configurator_agent.py +520 -0
  38. onec_runtime/controller_worker.py +400 -0
  39. onec_runtime/credentials.py +18 -0
  40. onec_runtime/epf_container.py +196 -0
  41. onec_runtime/errors.py +205 -0
  42. onec_runtime/experiment.py +130 -0
  43. onec_runtime/extension_bundle.py +944 -0
  44. onec_runtime/extension_lifecycle.py +402 -0
  45. onec_runtime/extension_state.py +222 -0
  46. onec_runtime/fault_injection.py +30 -0
  47. onec_runtime/kernel.py +179 -0
  48. onec_runtime/lease.py +123 -0
  49. onec_runtime/observation.py +287 -0
  50. onec_runtime/performance_profile.py +245 -0
  51. onec_runtime/privacy.py +263 -0
  52. onec_runtime/processes.py +265 -0
  53. onec_runtime/prototype_runtime.py +2644 -0
  54. onec_runtime/rdbg/__init__.py +1 -0
  55. onec_runtime/rdbg/models.py +130 -0
  56. onec_runtime/rdbg/reconnect.py +59 -0
  57. onec_runtime/rdbg/session.py +913 -0
  58. onec_runtime/rdbg/transport.py +138 -0
  59. onec_runtime/rdbg/xml_codec.py +980 -0
  60. onec_runtime/recovery.py +106 -0
  61. onec_runtime/recovery_journal.py +79 -0
  62. onec_runtime/resources/extension/OnecInteractiveRuntime.cfe +0 -0
  63. onec_runtime/resources/extension/extension-manifest.json +108 -0
  64. onec_runtime/runtime_api.py +5272 -0
  65. onec_runtime/runtime_contracts.py +196 -0
  66. onec_runtime/server_worker.py +2034 -0
  67. onec_runtime/session.py +2123 -0
  68. onec_runtime/startup_diagnostics.py +45 -0
  69. onec_runtime/stop_routing.py +65 -0
  70. onec_runtime/supervised_processes.py +232 -0
  71. onec_runtime/supervised_runtime.py +512 -0
  72. onec_runtime/supervisor.py +363 -0
  73. onec_runtime/supervisor_model.py +148 -0
  74. onec_runtime/supervisor_protocol.py +77 -0
  75. onec_runtime/table_materialization.py +471 -0
  76. onec_runtime/table_transfer_backend.py +203 -0
  77. onec_runtime/table_value.py +311 -0
  78. onec_runtime/toolchain.py +730 -0
  79. onec_runtime/value_materialization.py +432 -0
  80. onec_runtime/value_transfer_backend.py +199 -0
  81. onec_runtime/worker_breakpoints.py +1431 -0
  82. onec_runtime/worker_epf.py +313 -0
  83. onec_runtime/worker_epf_template.py +53 -0
  84. onec_runtime/worker_stage_protocol.py +516 -0
  85. onec_runtime/worker_universe.py +3772 -0
  86. onec_runtime_build/__init__.py +1 -0
  87. onec_runtime_build/parser_target_development.py +116 -0
@@ -0,0 +1,196 @@
1
+ """Immutable contracts shared by core runtime adapters."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping
6
+ from dataclasses import dataclass, replace
7
+ import re
8
+
9
+ from onec_runtime.bsl import (
10
+ DiagnosticStage,
11
+ MappingConfidence,
12
+ NormalizedDiagnostic,
13
+ SourceSpan,
14
+ SourceUnitRef,
15
+ VisibleSourceLocation,
16
+ )
17
+
18
+
19
+ MAX_DIAGNOSTIC_COORDINATE = 10_000_000
20
+ MAX_DIAGNOSTIC_LABEL_LENGTH = 128
21
+ MAX_PRIVATE_DIAGNOSTIC_LENGTH = 4_096
22
+
23
+ _DIAGNOSTIC_ID_RE = re.compile(r"[0-9a-f]{64}\Z")
24
+ _SHA256_RE = re.compile(r"[0-9a-f]{64}\Z")
25
+ _DIAGNOSTIC_LABEL_RE = re.compile(r"[a-z][a-z0-9_]{0,127}\Z")
26
+ _DIAGNOSTIC_SUMMARIES = {
27
+ DiagnosticStage.PARSING: "BSL parsing failed",
28
+ DiagnosticStage.LOWERING: "BSL lowering failed",
29
+ DiagnosticStage.COMPILATION: "BSL compilation failed",
30
+ DiagnosticStage.EXECUTION: "BSL execution failed",
31
+ }
32
+ _EXECUTION_MODES = frozenset({"main", "capture", "worker"})
33
+
34
+
35
+ def sanitize_normalized_diagnostic(
36
+ value: object,
37
+ ) -> NormalizedDiagnostic | None:
38
+ """Return a canonical bounded diagnostic or fail closed without raising."""
39
+ try:
40
+ if not isinstance(value, NormalizedDiagnostic):
41
+ return None
42
+ if type(value.stage) is not DiagnosticStage:
43
+ return None
44
+ if type(value.mapping_confidence) is not MappingConfidence:
45
+ return None
46
+ if (
47
+ type(value.diagnostic_id) is not str
48
+ or _DIAGNOSTIC_ID_RE.fullmatch(value.diagnostic_id) is None
49
+ ):
50
+ return None
51
+ if value.code is not None and (
52
+ type(value.code) is not str
53
+ or len(value.code) > MAX_DIAGNOSTIC_LABEL_LENGTH
54
+ or _DIAGNOSTIC_LABEL_RE.fullmatch(value.code) is None
55
+ ):
56
+ return None
57
+ if value.synthetic_region is not None and (
58
+ type(value.synthetic_region) is not str
59
+ or len(value.synthetic_region) > MAX_DIAGNOSTIC_LABEL_LENGTH
60
+ or _DIAGNOSTIC_LABEL_RE.fullmatch(value.synthetic_region) is None
61
+ ):
62
+ return None
63
+ if value.source_unit is not None and (
64
+ not isinstance(value.source_unit, SourceUnitRef)
65
+ or len(value.source_unit.unit_id) > 256
66
+ ):
67
+ return None
68
+ if value.visible_location is not None:
69
+ location = value.visible_location
70
+ if (
71
+ not isinstance(location, VisibleSourceLocation)
72
+ or not _bounded_positive_coordinate(location.line)
73
+ or not _bounded_positive_coordinate(location.column)
74
+ or not _bounded_span(location.span)
75
+ or len(location.source_unit.unit_id) > 256
76
+ or (
77
+ value.source_unit is not None
78
+ and location.source_unit != value.source_unit
79
+ )
80
+ ):
81
+ return None
82
+ if value.related_visible_span is not None and not _bounded_span(
83
+ value.related_visible_span
84
+ ):
85
+ return None
86
+ if value.lowered_location is not None:
87
+ location = value.lowered_location
88
+ if (
89
+ not _bounded_positive_coordinate(location.line)
90
+ or not _bounded_positive_coordinate(location.column)
91
+ or type(location.offset) is not int
92
+ or not 0 <= location.offset <= MAX_DIAGNOSTIC_COORDINATE
93
+ or not _bounded_span(location.span)
94
+ ):
95
+ return None
96
+ for name in (
97
+ "platform_diagnostic_sha256",
98
+ "execution_artifact_sha256",
99
+ "source_map_sha256",
100
+ ):
101
+ digest = getattr(value, name)
102
+ if digest is not None and (
103
+ type(digest) is not str or _SHA256_RE.fullmatch(digest) is None
104
+ ):
105
+ return None
106
+ if type(value.platform_diagnostic_truncated) is not bool or type(
107
+ value.platform_diagnostic_redacted
108
+ ) is not bool:
109
+ return None
110
+ platform_diagnostic = value.platform_diagnostic
111
+ if platform_diagnostic is not None and (
112
+ type(platform_diagnostic) is not str
113
+ or len(platform_diagnostic) > MAX_PRIVATE_DIAGNOSTIC_LENGTH
114
+ or value.platform_diagnostic_sha256 is None
115
+ ):
116
+ return None
117
+ return replace(
118
+ value,
119
+ runtime_summary=_DIAGNOSTIC_SUMMARIES[value.stage],
120
+ )
121
+ except BaseException:
122
+ return None
123
+
124
+
125
+ def _bounded_positive_coordinate(value: object) -> bool:
126
+ return type(value) is int and 1 <= value <= MAX_DIAGNOSTIC_COORDINATE
127
+
128
+
129
+ def _bounded_span(value: object) -> bool:
130
+ return (
131
+ isinstance(value, SourceSpan)
132
+ and type(value.start) is int
133
+ and type(value.end) is int
134
+ and 0 <= value.start <= value.end <= MAX_DIAGNOSTIC_COORDINATE
135
+ )
136
+
137
+
138
+ @dataclass(frozen=True, slots=True)
139
+ class OperationExecutionProvenance:
140
+ """Hash-only identity of the exact artifact admitted for one operation."""
141
+
142
+ visible_source_sha256: str
143
+ executed_source_sha256: str
144
+ source_map_sha256: str
145
+ mode: str
146
+ worker_generation: int | None = None
147
+ worker_manifest_sha256: str | None = None
148
+
149
+ def __post_init__(self) -> None:
150
+ for name in (
151
+ "visible_source_sha256",
152
+ "executed_source_sha256",
153
+ "source_map_sha256",
154
+ ):
155
+ value = getattr(self, name)
156
+ if type(value) is not str or _SHA256_RE.fullmatch(value) is None:
157
+ raise ValueError(f"{name} must be a lowercase sha256")
158
+ if type(self.mode) is not str or self.mode not in _EXECUTION_MODES:
159
+ raise ValueError("mode must be an allowlisted code mode")
160
+ if self.worker_generation is not None and (
161
+ type(self.worker_generation) is not int
162
+ or not 0 <= self.worker_generation <= MAX_DIAGNOSTIC_COORDINATE
163
+ ):
164
+ raise ValueError(
165
+ "worker_generation must be a bounded non-negative integer"
166
+ )
167
+ if self.worker_manifest_sha256 is not None and (
168
+ type(self.worker_manifest_sha256) is not str
169
+ or _SHA256_RE.fullmatch(self.worker_manifest_sha256) is None
170
+ ):
171
+ raise ValueError("worker_manifest_sha256 must be a lowercase sha256")
172
+
173
+ @classmethod
174
+ def from_wire(cls, value: object) -> "OperationExecutionProvenance":
175
+ if isinstance(value, cls):
176
+ return value
177
+ if not isinstance(value, Mapping):
178
+ raise TypeError("execution provenance must be a mapping")
179
+ expected = {
180
+ "visible_source_sha256",
181
+ "executed_source_sha256",
182
+ "source_map_sha256",
183
+ "mode",
184
+ "worker_generation",
185
+ "worker_manifest_sha256",
186
+ }
187
+ if set(value) != expected:
188
+ raise ValueError("execution provenance has an invalid wire shape")
189
+ return cls(
190
+ visible_source_sha256=value.get("visible_source_sha256"), # type: ignore[arg-type]
191
+ executed_source_sha256=value.get("executed_source_sha256"), # type: ignore[arg-type]
192
+ source_map_sha256=value.get("source_map_sha256"), # type: ignore[arg-type]
193
+ mode=value.get("mode"), # type: ignore[arg-type]
194
+ worker_generation=value.get("worker_generation"), # type: ignore[arg-type]
195
+ worker_manifest_sha256=value.get("worker_manifest_sha256"), # type: ignore[arg-type]
196
+ )