ruml-parser 1.0.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.
Files changed (72) hide show
  1. ruml_parser/__init__.py +183 -0
  2. ruml_parser/internal/__init__.py +2 -0
  3. ruml_parser/internal/extension.py +91 -0
  4. ruml_parser/internal/mapping.py +731 -0
  5. ruml_parser/internal/ruml/__init__.py +237 -0
  6. ruml_parser/internal/ruml/actions/__init__.py +2 -0
  7. ruml_parser/internal/ruml/actions/actions_capability_declaration.py +23 -0
  8. ruml_parser/internal/ruml/actions/actions_node_capability.py +40 -0
  9. ruml_parser/internal/ruml/ai_query/__init__.py +2 -0
  10. ruml_parser/internal/ruml/ai_query/ai_query_capability_declaration.py +25 -0
  11. ruml_parser/internal/ruml/ai_query/ai_query_node_capability.py +66 -0
  12. ruml_parser/internal/ruml/aliases.py +93 -0
  13. ruml_parser/internal/ruml/capability/__init__.py +2 -0
  14. ruml_parser/internal/ruml/capability/abstract_capability_declaration.py +23 -0
  15. ruml_parser/internal/ruml/capability/abstract_node_capability.py +14 -0
  16. ruml_parser/internal/ruml/capability/capability_declaration.py +52 -0
  17. ruml_parser/internal/ruml/capability/capability_declarations.py +199 -0
  18. ruml_parser/internal/ruml/capability/extension_node_capability.py +17 -0
  19. ruml_parser/internal/ruml/capability/node_capabilities.py +113 -0
  20. ruml_parser/internal/ruml/capability/other_node_capability.py +21 -0
  21. ruml_parser/internal/ruml/context/__init__.py +2 -0
  22. ruml_parser/internal/ruml/context/context.py +40 -0
  23. ruml_parser/internal/ruml/context/context_capability_declaration.py +25 -0
  24. ruml_parser/internal/ruml/context/context_refs_node_capability.py +17 -0
  25. ruml_parser/internal/ruml/datapoints/__init__.py +2 -0
  26. ruml_parser/internal/ruml/datapoints/datapoint.py +101 -0
  27. ruml_parser/internal/ruml/datapoints/datapoint_set.py +20 -0
  28. ruml_parser/internal/ruml/datapoints/datapoints_capability_declaration.py +29 -0
  29. ruml_parser/internal/ruml/datapoints/option.py +11 -0
  30. ruml_parser/internal/ruml/expression/__init__.py +2 -0
  31. ruml_parser/internal/ruml/expression/expression_capability_declaration.py +23 -0
  32. ruml_parser/internal/ruml/expression/expression_node_capability.py +20 -0
  33. ruml_parser/internal/ruml/metadata.py +83 -0
  34. ruml_parser/internal/ruml/nodes/__init__.py +2 -0
  35. ruml_parser/internal/ruml/nodes/abstract_node.py +29 -0
  36. ruml_parser/internal/ruml/nodes/branch_node.py +15 -0
  37. ruml_parser/internal/ruml/nodes/leaf_node.py +10 -0
  38. ruml_parser/internal/ruml/nodes/node.py +6 -0
  39. ruml_parser/internal/ruml/protocol/__init__.py +2 -0
  40. ruml_parser/internal/ruml/protocol/protocol_capability_declaration.py +29 -0
  41. ruml_parser/internal/ruml/query/__init__.py +2 -0
  42. ruml_parser/internal/ruml/query/query_capability_declaration.py +23 -0
  43. ruml_parser/internal/ruml/query/query_node_capability.py +17 -0
  44. ruml_parser/internal/ruml/ruml_document.py +45 -0
  45. ruml_parser/internal/ruml/text_reference/__init__.py +2 -0
  46. ruml_parser/internal/ruml/text_reference/text.py +69 -0
  47. ruml_parser/internal/ruml/text_reference/text_reference_capability_declaration.py +25 -0
  48. ruml_parser/internal/ruml/text_reference/text_refs_node_capability.py +32 -0
  49. ruml_parser/internal/ruml/tree/__init__.py +2 -0
  50. ruml_parser/internal/ruml/tree/tree_capability_declarations.py +30 -0
  51. ruml_parser/internal/validation/__init__.py +14 -0
  52. ruml_parser/internal/validation/capabilities.py +227 -0
  53. ruml_parser/internal/validation/contexts.py +51 -0
  54. ruml_parser/internal/validation/datapoint_sets.py +125 -0
  55. ruml_parser/internal/validation/modular.py +42 -0
  56. ruml_parser/internal/validation/recursion.py +197 -0
  57. ruml_parser/internal/validation/root.py +36 -0
  58. ruml_parser/internal/validation/texts.py +50 -0
  59. ruml_parser/model/__init__.py +2 -0
  60. ruml_parser/model/ruml.py +1156 -0
  61. ruml_parser/model/ruml_result.py +430 -0
  62. ruml_parser/node_result_status.py +19 -0
  63. ruml_parser/pydantic.py +96 -0
  64. ruml_parser/ruml_parser.py +75 -0
  65. ruml_parser/schema_files.py +23 -0
  66. ruml_parser/schema_validation.py +354 -0
  67. ruml_parser/structural_error.py +36 -0
  68. ruml_parser/text.py +220 -0
  69. ruml_parser-1.0.0.dist-info/METADATA +119 -0
  70. ruml_parser-1.0.0.dist-info/RECORD +72 -0
  71. ruml_parser-1.0.0.dist-info/WHEEL +4 -0
  72. ruml_parser-1.0.0.dist-info/licenses/LICENSE +73 -0
@@ -0,0 +1,237 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """RUML models for internal use: dataclass "twins" of `ruml_parser.model.ruml`.
4
+
5
+ The Pydantic models in `ruml_parser.model.ruml` are generated from the JSON schema and
6
+ remain the public parsing API, but they inherit every limitation of the schema (itself
7
+ constrained by what is expressible in JSON Schema), the code generator, and of what a
8
+ single Pydantic model can express: capability entries whose payload type is not selected
9
+ by their id, `anyOf` workarounds rendered as `Actions1 | Actions2 | Actions3`, placeholder
10
+ names like `Type1`, optional collections that mean the same as empty ones, and so on.
11
+ This package is the hand-written twin that fixes those where it matters;
12
+ `ruml_parser.internal.mapping` translates a validated Pydantic document into it.
13
+
14
+ Conventions:
15
+
16
+ - Instances are only ever built from validated Pydantic models, so the dataclasses carry
17
+ no validation and no constraints. Where the schema constrains a string (a pattern or a
18
+ length), the docstring records it for the reader. The spec's cross-object rules, which
19
+ no type can express, are checked by `ruml_parser.internal.validation` on the built
20
+ document instead.
21
+ - Names are snake_case, and generated placeholder names get real ones (`Type1` →
22
+ `DatapointType`).
23
+ - Collections *of entries* (children, tags, capability data maps, metadata) are never
24
+ optional: an absent one is an empty one. Free-form *payload* objects (`content`,
25
+ `source`, `config`, `default_value`) stay optional because absence is meaningful
26
+ there. Fields with a schema default take that default instead of `None`.
27
+ - Instances are frozen. Sequences and maps are typed as `Sequence` and `Mapping` (built
28
+ as lists and dicts) so they do not invite mutation either.
29
+ - Enums are reused from the generated module: they are plain `StrEnum`s whose members
30
+ are the spec's to choose, so a copy would add nothing but a second place to edit.
31
+
32
+ Keeping in sync: every field of both sides is named in the mappers, so a field that the
33
+ regenerated `ruml.py` renames, retypes or removes fails type checking. A field the
34
+ schema *adds* is not flagged that way — after `make update-ruml-models`, diff `ruml.py`
35
+ for additions and decide whether this model should carry them.
36
+ """
37
+
38
+ from ruml_parser.internal.ruml.actions.actions_capability_declaration import (
39
+ ActionsCapabilityDeclaration,
40
+ )
41
+ from ruml_parser.internal.ruml.actions.actions_node_capability import (
42
+ Action,
43
+ ActionsNodeCapability,
44
+ )
45
+ from ruml_parser.internal.ruml.ai_query.ai_query_capability_declaration import (
46
+ AiQueryCapabilityDeclaration,
47
+ AiQueryDeclarationConfig,
48
+ )
49
+ from ruml_parser.internal.ruml.ai_query.ai_query_node_capability import (
50
+ AiQueryNodeCapability,
51
+ AiQueryNodeConfig,
52
+ ContextInput,
53
+ QueryInputs,
54
+ )
55
+ from ruml_parser.internal.ruml.aliases import (
56
+ CapabilityId,
57
+ CapabilityPayload,
58
+ CapabilityRole,
59
+ ContextCategory,
60
+ ContextId,
61
+ ContextRole,
62
+ ContextType,
63
+ DatapointId,
64
+ DatapointType,
65
+ DecisionMode,
66
+ DerivationType,
67
+ DocumentStatus,
68
+ DocumentType,
69
+ Effort,
70
+ ExternalSourceType,
71
+ Hash,
72
+ LanguageCode,
73
+ LegislativeStatus,
74
+ LexId,
75
+ OfficialCapabilityId,
76
+ Operator,
77
+ ProtocolLevel,
78
+ SetId,
79
+ TextAnchorType,
80
+ TextId,
81
+ TextType,
82
+ )
83
+ from ruml_parser.internal.ruml.capability.abstract_capability_declaration import (
84
+ AbstractCapabilityDeclaration,
85
+ )
86
+ from ruml_parser.internal.ruml.capability.abstract_node_capability import (
87
+ AbstractNodeCapability,
88
+ )
89
+ from ruml_parser.internal.ruml.capability.capability_declaration import (
90
+ CapabilityDeclarationWithData,
91
+ DraftCapabilityDeclaration,
92
+ ExtensionCapabilityDeclaration,
93
+ )
94
+ from ruml_parser.internal.ruml.capability.capability_declarations import (
95
+ CapabilityDeclarations,
96
+ )
97
+ from ruml_parser.internal.ruml.capability.extension_node_capability import (
98
+ ExtensionNodeCapability,
99
+ )
100
+ from ruml_parser.internal.ruml.capability.node_capabilities import (
101
+ NodeCapabilities,
102
+ NodeCapability,
103
+ )
104
+ from ruml_parser.internal.ruml.capability.other_node_capability import (
105
+ OtherNodeCapability,
106
+ )
107
+ from ruml_parser.internal.ruml.context.context import Context
108
+ from ruml_parser.internal.ruml.context.context_capability_declaration import (
109
+ ContextCapabilityDeclaration,
110
+ )
111
+ from ruml_parser.internal.ruml.context.context_refs_node_capability import (
112
+ ContextRefsNodeCapability,
113
+ )
114
+ from ruml_parser.internal.ruml.datapoints.datapoint import (
115
+ Cardinality,
116
+ Datapoint,
117
+ ExternalBinding,
118
+ InputBinding,
119
+ Validation,
120
+ )
121
+ from ruml_parser.internal.ruml.datapoints.datapoint_set import DatapointSet
122
+ from ruml_parser.internal.ruml.datapoints.datapoints_capability_declaration import (
123
+ DatapointsCapabilityDeclaration,
124
+ )
125
+ from ruml_parser.internal.ruml.datapoints.option import Option
126
+ from ruml_parser.internal.ruml.expression.expression_capability_declaration import (
127
+ ExpressionCapabilityDeclaration,
128
+ )
129
+ from ruml_parser.internal.ruml.expression.expression_node_capability import (
130
+ ExpressionNodeCapability,
131
+ )
132
+ from ruml_parser.internal.ruml.metadata import Author, DerivedFrom, Metadata
133
+ from ruml_parser.internal.ruml.nodes.abstract_node import AbstractNode
134
+ from ruml_parser.internal.ruml.nodes.branch_node import BranchNode
135
+ from ruml_parser.internal.ruml.nodes.leaf_node import LeafNode
136
+ from ruml_parser.internal.ruml.nodes.node import Node
137
+ from ruml_parser.internal.ruml.protocol.protocol_capability_declaration import (
138
+ ProtocolCapabilityDeclaration,
139
+ ProtocolConfig,
140
+ )
141
+ from ruml_parser.internal.ruml.query.query_capability_declaration import (
142
+ QueryCapabilityDeclaration,
143
+ )
144
+ from ruml_parser.internal.ruml.query.query_node_capability import QueryNodeCapability
145
+ from ruml_parser.internal.ruml.ruml_document import RumlDocument
146
+ from ruml_parser.internal.ruml.text_reference.text import Text, TextSource
147
+ from ruml_parser.internal.ruml.text_reference.text_reference_capability_declaration import (
148
+ TextReferenceCapabilityDeclaration,
149
+ )
150
+ from ruml_parser.internal.ruml.text_reference.text_refs_node_capability import (
151
+ TextAnchor,
152
+ TextRefsNodeCapability,
153
+ )
154
+ from ruml_parser.internal.ruml.tree.tree_capability_declarations import (
155
+ TreeIncludeCapabilityDeclaration,
156
+ TreeReferenceCapabilityDeclaration,
157
+ )
158
+
159
+ __all__ = [
160
+ "AbstractCapabilityDeclaration",
161
+ "AbstractNode",
162
+ "AbstractNodeCapability",
163
+ "Action",
164
+ "ActionsCapabilityDeclaration",
165
+ "ActionsNodeCapability",
166
+ "AiQueryCapabilityDeclaration",
167
+ "AiQueryDeclarationConfig",
168
+ "AiQueryNodeCapability",
169
+ "AiQueryNodeConfig",
170
+ "Author",
171
+ "BranchNode",
172
+ "CapabilityDeclarationWithData",
173
+ "CapabilityDeclarations",
174
+ "CapabilityId",
175
+ "CapabilityPayload",
176
+ "CapabilityRole",
177
+ "Cardinality",
178
+ "Context",
179
+ "ContextCapabilityDeclaration",
180
+ "ContextCategory",
181
+ "ContextId",
182
+ "ContextInput",
183
+ "ContextRefsNodeCapability",
184
+ "ContextRole",
185
+ "ContextType",
186
+ "Datapoint",
187
+ "DatapointId",
188
+ "DatapointSet",
189
+ "DatapointType",
190
+ "DatapointsCapabilityDeclaration",
191
+ "DecisionMode",
192
+ "DerivationType",
193
+ "DerivedFrom",
194
+ "DocumentStatus",
195
+ "DocumentType",
196
+ "Effort",
197
+ "DraftCapabilityDeclaration",
198
+ "ExpressionCapabilityDeclaration",
199
+ "ExpressionNodeCapability",
200
+ "ExtensionCapabilityDeclaration",
201
+ "ExtensionNodeCapability",
202
+ "ExternalBinding",
203
+ "ExternalSourceType",
204
+ "Hash",
205
+ "InputBinding",
206
+ "LanguageCode",
207
+ "LeafNode",
208
+ "LegislativeStatus",
209
+ "LexId",
210
+ "Metadata",
211
+ "Node",
212
+ "NodeCapabilities",
213
+ "NodeCapability",
214
+ "OfficialCapabilityId",
215
+ "Operator",
216
+ "Option",
217
+ "OtherNodeCapability",
218
+ "ProtocolCapabilityDeclaration",
219
+ "ProtocolConfig",
220
+ "ProtocolLevel",
221
+ "QueryCapabilityDeclaration",
222
+ "QueryInputs",
223
+ "QueryNodeCapability",
224
+ "RumlDocument",
225
+ "SetId",
226
+ "Text",
227
+ "TextAnchor",
228
+ "TextAnchorType",
229
+ "TextId",
230
+ "TextReferenceCapabilityDeclaration",
231
+ "TextRefsNodeCapability",
232
+ "TextSource",
233
+ "TextType",
234
+ "TreeIncludeCapabilityDeclaration",
235
+ "TreeReferenceCapabilityDeclaration",
236
+ "Validation",
237
+ ]
@@ -0,0 +1,2 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,23 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from collections.abc import Mapping
4
+ from dataclasses import dataclass
5
+ from typing import Any
6
+
7
+ from ruml_parser.internal.ruml.aliases import CapabilityRole, OfficialCapabilityId
8
+ from ruml_parser.internal.ruml.capability.abstract_capability_declaration import (
9
+ AbstractCapabilityDeclaration,
10
+ )
11
+
12
+
13
+ @dataclass(frozen=True, slots=True, kw_only=True)
14
+ class ActionsCapabilityDeclaration(AbstractCapabilityDeclaration):
15
+ """Root-level declaration of `ruml:actions` (`PlainPayload`)."""
16
+
17
+ id = str(OfficialCapabilityId.ruml_actions)
18
+ role = CapabilityRole.reaction
19
+
20
+ required: bool = False
21
+ """Whether this capability must be resolved to evaluate"""
22
+ config: Mapping[str, Any] | None = None
23
+ """Capability-specific configuration"""
@@ -0,0 +1,40 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from collections.abc import Mapping
4
+ from dataclasses import dataclass
5
+ from typing import Any
6
+
7
+ from ruml_parser.internal.ruml.aliases import OfficialCapabilityId
8
+ from ruml_parser.internal.ruml.capability.abstract_node_capability import (
9
+ AbstractNodeCapability,
10
+ )
11
+
12
+
13
+ @dataclass(frozen=True, slots=True, kw_only=True)
14
+ class Action:
15
+ operation: str
16
+ """The operation to perform (open vocabulary)"""
17
+ ref: str
18
+ """Symbolic reference to the operation implementation"""
19
+ config: Mapping[str, Any] | None = None
20
+ """Optional, runtime-defined configuration for the action"""
21
+
22
+
23
+ @dataclass(frozen=True, slots=True, kw_only=True)
24
+ class ActionsNodeCapability(AbstractNodeCapability):
25
+ """The actions declared for a node; at least one of the three is set.
26
+
27
+ The schema expresses "at least one" as an `anyOf` over three otherwise identical
28
+ objects, which the codegen renders as `Actions1 | Actions2 | Actions3`.
29
+ """
30
+
31
+ id = str(OfficialCapabilityId.ruml_actions)
32
+
33
+ description: str | None = None
34
+ """Description of the actions declared for the node"""
35
+ on_true: Action | None = None
36
+ """Action to run when the node evaluates to true"""
37
+ on_false: Action | None = None
38
+ """Action to run when the node evaluates to false"""
39
+ on_undefined: Action | None = None
40
+ """Action to run when the node evaluates to undefined"""
@@ -0,0 +1,2 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,25 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from dataclasses import dataclass
4
+
5
+ from ruml_parser.internal.ruml.aliases import CapabilityRole, OfficialCapabilityId
6
+ from ruml_parser.internal.ruml.capability.abstract_capability_declaration import (
7
+ AbstractCapabilityDeclaration,
8
+ )
9
+
10
+
11
+ @dataclass(frozen=True, slots=True, kw_only=True)
12
+ class AiQueryDeclarationConfig:
13
+ system_prompt: str | None = None
14
+ """System prompt applied to all AI queries in the document"""
15
+
16
+
17
+ @dataclass(frozen=True, slots=True, kw_only=True)
18
+ class AiQueryCapabilityDeclaration(AbstractCapabilityDeclaration):
19
+ id = str(OfficialCapabilityId.ruml_ai_query)
20
+ role = CapabilityRole.decision
21
+
22
+ required: bool = False
23
+ """Whether this capability must be resolved to evaluate"""
24
+ config: AiQueryDeclarationConfig | None = None
25
+ """Root-level configuration for the AI query capability"""
@@ -0,0 +1,66 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from collections.abc import Sequence
4
+ from dataclasses import dataclass, field
5
+
6
+ from ruml_parser.internal.ruml.aliases import (
7
+ ContextRole,
8
+ Effort,
9
+ OfficialCapabilityId,
10
+ )
11
+ from ruml_parser.internal.ruml.capability.abstract_node_capability import (
12
+ AbstractNodeCapability,
13
+ )
14
+ from ruml_parser.model import ruml as model
15
+
16
+
17
+ @dataclass(frozen=True, slots=True, kw_only=True)
18
+ class ContextInput:
19
+ """A context entry supplied as input to an AI query.
20
+
21
+ The schema also allows a bare id string, meaning role `reference`; the mapping
22
+ normalizes that to this form.
23
+ """
24
+
25
+ id: str
26
+ """Id of the referenced context entry"""
27
+ role: ContextRole = model.Role.reference
28
+ """Role the context plays in the query"""
29
+
30
+
31
+ @dataclass(frozen=True, slots=True, kw_only=True)
32
+ class QueryInputs:
33
+ """Inputs supplied to an AI query."""
34
+
35
+ context: Sequence[ContextInput] = field(default_factory=list)
36
+ """Context entries supplied as input to the query"""
37
+ datapoints: Sequence[str] = field(default_factory=list)
38
+ """Ids of datapoints supplied as input to the query"""
39
+ texts: Sequence[str] = field(default_factory=list)
40
+ """Ids of texts supplied as input to the query"""
41
+
42
+
43
+ @dataclass(frozen=True, slots=True, kw_only=True)
44
+ class AiQueryNodeConfig:
45
+ deterministic: bool | None = None
46
+ """Whether the query should be evaluated deterministically"""
47
+ effort: Effort = model.Effort.medium
48
+ """Effort the model should spend on the query"""
49
+ temperature: float | None = None
50
+ """Sampling temperature for the query, between 0 and 1"""
51
+
52
+
53
+ @dataclass(frozen=True, slots=True, kw_only=True)
54
+ class AiQueryNodeCapability(AbstractNodeCapability):
55
+ id = str(OfficialCapabilityId.ruml_ai_query)
56
+
57
+ model: str
58
+ """Symbolic reference to the AI model, resolved by the tool at runtime"""
59
+ prompt: str | None = None
60
+ """Prompt evaluated for this node"""
61
+ description: str | None = None
62
+ """Description of what the query determines"""
63
+ inputs: QueryInputs = field(default_factory=QueryInputs)
64
+ """Inputs (context, datapoints, texts) supplied to the query"""
65
+ config: AiQueryNodeConfig | None = None
66
+ """Node-level configuration for the query"""
@@ -0,0 +1,93 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from collections.abc import Mapping
4
+ from typing import Any
5
+
6
+ from ruml_parser.model import ruml as model
7
+
8
+ DocumentStatus = model.DocumentStatus
9
+
10
+
11
+ DocumentType = model.DocumentType
12
+
13
+
14
+ DerivationType = model.DerivationType
15
+
16
+
17
+ LegislativeStatus = model.Status
18
+
19
+
20
+ Operator = model.Operator
21
+
22
+
23
+ DecisionMode = model.DecisionMode
24
+
25
+
26
+ DatapointType = model.Type
27
+
28
+
29
+ ExternalSourceType = model.SourceType
30
+
31
+
32
+ TextType = model.Type2
33
+
34
+
35
+ TextAnchorType = model.Type3
36
+
37
+
38
+ ContextCategory = model.Category
39
+
40
+
41
+ ContextType = model.Type4
42
+
43
+
44
+ ContextRole = model.Role
45
+
46
+
47
+ Effort = model.Effort
48
+
49
+
50
+ ProtocolLevel = model.Level
51
+
52
+
53
+ OfficialCapabilityId = model.OfficialCapabilityId
54
+
55
+
56
+ CapabilityRole = model.Role1
57
+
58
+
59
+ type LexId = str
60
+ """Key of a node in the rulemap: a positive integer without leading zeros."""
61
+
62
+
63
+ type DatapointId = str
64
+ """Id of a datapoint: lower-case snake_case, `[a-z_][a-z0-9_]*` (DP-02)."""
65
+
66
+
67
+ type SetId = str
68
+ """Id of a datapoint set: lower-case snake_case, `[a-z_][a-z0-9_]*` (DP-02)."""
69
+
70
+
71
+ type TextId = str
72
+ """Id of a root-level text entry: lower-case snake_case, `[a-z_][a-z0-9_]*` (TXT-02)."""
73
+
74
+
75
+ type ContextId = str
76
+ """Id of a root-level context entry: lower-case snake_case, `[a-z_][a-z0-9_]*` (CTX-04)."""
77
+
78
+
79
+ type CapabilityId = str
80
+ """A capability id: official (`ruml:query`), draft (`ruml:draft/my-capability`) or
81
+ third-party in reverse-domain form (`com.example/my-capability`)."""
82
+
83
+
84
+ type Hash = str
85
+ """An integrity hash in the form `<algorithm>:<hex value>`."""
86
+
87
+
88
+ type LanguageCode = str
89
+ """An ISO 639-1 two-letter language code."""
90
+
91
+
92
+ type CapabilityPayload = Mapping[str, Any]
93
+ """Free-form (root or node-level) payload of a capability without a dedicated model."""
@@ -0,0 +1,2 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,23 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from abc import ABC, abstractmethod
4
+
5
+ from ruml_parser.internal.ruml.aliases import CapabilityId, CapabilityRole
6
+
7
+
8
+ class AbstractCapabilityDeclaration(ABC):
9
+ """Base class for all root-level capability declarations."""
10
+
11
+ @property
12
+ @abstractmethod
13
+ def id(self) -> CapabilityId:
14
+ """The id of the declared capability."""
15
+
16
+ @property
17
+ @abstractmethod
18
+ def role(self) -> CapabilityRole:
19
+ """The role the capability plays (§4.1).
20
+
21
+ Fixed by its chapter for an official id, and by the extension for an extension
22
+ capability; declared in the document for any other.
23
+ """
@@ -0,0 +1,14 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from abc import ABC, abstractmethod
4
+
5
+ from ruml_parser.internal.ruml.aliases import CapabilityId
6
+
7
+
8
+ class AbstractNodeCapability(ABC):
9
+ """Base class for all Node Capabilities."""
10
+
11
+ @property
12
+ @abstractmethod
13
+ def id(self) -> CapabilityId:
14
+ pass
@@ -0,0 +1,52 @@
1
+ # SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from abc import ABC
4
+ from collections.abc import Mapping
5
+ from dataclasses import dataclass, field
6
+ from typing import Any
7
+
8
+ from ruml_parser.internal.ruml.aliases import CapabilityId, CapabilityRole
9
+ from ruml_parser.internal.ruml.capability.abstract_capability_declaration import (
10
+ AbstractCapabilityDeclaration,
11
+ )
12
+
13
+
14
+ @dataclass(frozen=True, slots=True, kw_only=True)
15
+ class DraftCapabilityDeclaration(AbstractCapabilityDeclaration):
16
+ """Root-level declaration of a draft capability (`ruml:draft/...`, `PlainPayload`)."""
17
+
18
+ id: CapabilityId = field()
19
+ """The id of the declared capability"""
20
+ required: bool = False
21
+ """Whether this capability must be resolved to evaluate"""
22
+ role: CapabilityRole = field()
23
+ """The role the capability declares (§4.1; CAP-03 makes declaring it mandatory)"""
24
+ config: Mapping[str, Any] | None = None
25
+ """Capability-specific configuration"""
26
+
27
+
28
+ @dataclass(frozen=True, slots=True, kw_only=True)
29
+ class CapabilityDeclarationWithData(AbstractCapabilityDeclaration):
30
+ """Root-level declaration of a third-party capability (payload left open)."""
31
+
32
+ id: CapabilityId = field()
33
+ """The id of the declared capability"""
34
+ required: bool = False
35
+ """Whether this capability must be resolved to evaluate"""
36
+ role: CapabilityRole = field()
37
+ """The role the capability declares (§4.1; CAP-03 makes declaring it mandatory)"""
38
+ data: Mapping[str, Any] = field(default_factory=dict)
39
+ """Capability-specific data payload, keyed by entry id"""
40
+ config: Mapping[str, Any] | None = None
41
+ """Capability-specific configuration"""
42
+
43
+
44
+ @dataclass(frozen=True, slots=True, kw_only=True)
45
+ class ExtensionCapabilityDeclaration(AbstractCapabilityDeclaration, ABC):
46
+ """Base class for root-level declarations of a capability an extension models.
47
+
48
+ The extension is a ``ruml_parser.internal.extension.CapabilityExtension``.
49
+ Subclasses are dataclasses defined by the extension, frozen like this one, with the
50
+ entry's ``required`` flag next to the payload's fields, and the capability's ``id``
51
+ and ``role`` as class attributes.
52
+ """