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.
- ruml_parser/__init__.py +183 -0
- ruml_parser/internal/__init__.py +2 -0
- ruml_parser/internal/extension.py +91 -0
- ruml_parser/internal/mapping.py +731 -0
- ruml_parser/internal/ruml/__init__.py +237 -0
- ruml_parser/internal/ruml/actions/__init__.py +2 -0
- ruml_parser/internal/ruml/actions/actions_capability_declaration.py +23 -0
- ruml_parser/internal/ruml/actions/actions_node_capability.py +40 -0
- ruml_parser/internal/ruml/ai_query/__init__.py +2 -0
- ruml_parser/internal/ruml/ai_query/ai_query_capability_declaration.py +25 -0
- ruml_parser/internal/ruml/ai_query/ai_query_node_capability.py +66 -0
- ruml_parser/internal/ruml/aliases.py +93 -0
- ruml_parser/internal/ruml/capability/__init__.py +2 -0
- ruml_parser/internal/ruml/capability/abstract_capability_declaration.py +23 -0
- ruml_parser/internal/ruml/capability/abstract_node_capability.py +14 -0
- ruml_parser/internal/ruml/capability/capability_declaration.py +52 -0
- ruml_parser/internal/ruml/capability/capability_declarations.py +199 -0
- ruml_parser/internal/ruml/capability/extension_node_capability.py +17 -0
- ruml_parser/internal/ruml/capability/node_capabilities.py +113 -0
- ruml_parser/internal/ruml/capability/other_node_capability.py +21 -0
- ruml_parser/internal/ruml/context/__init__.py +2 -0
- ruml_parser/internal/ruml/context/context.py +40 -0
- ruml_parser/internal/ruml/context/context_capability_declaration.py +25 -0
- ruml_parser/internal/ruml/context/context_refs_node_capability.py +17 -0
- ruml_parser/internal/ruml/datapoints/__init__.py +2 -0
- ruml_parser/internal/ruml/datapoints/datapoint.py +101 -0
- ruml_parser/internal/ruml/datapoints/datapoint_set.py +20 -0
- ruml_parser/internal/ruml/datapoints/datapoints_capability_declaration.py +29 -0
- ruml_parser/internal/ruml/datapoints/option.py +11 -0
- ruml_parser/internal/ruml/expression/__init__.py +2 -0
- ruml_parser/internal/ruml/expression/expression_capability_declaration.py +23 -0
- ruml_parser/internal/ruml/expression/expression_node_capability.py +20 -0
- ruml_parser/internal/ruml/metadata.py +83 -0
- ruml_parser/internal/ruml/nodes/__init__.py +2 -0
- ruml_parser/internal/ruml/nodes/abstract_node.py +29 -0
- ruml_parser/internal/ruml/nodes/branch_node.py +15 -0
- ruml_parser/internal/ruml/nodes/leaf_node.py +10 -0
- ruml_parser/internal/ruml/nodes/node.py +6 -0
- ruml_parser/internal/ruml/protocol/__init__.py +2 -0
- ruml_parser/internal/ruml/protocol/protocol_capability_declaration.py +29 -0
- ruml_parser/internal/ruml/query/__init__.py +2 -0
- ruml_parser/internal/ruml/query/query_capability_declaration.py +23 -0
- ruml_parser/internal/ruml/query/query_node_capability.py +17 -0
- ruml_parser/internal/ruml/ruml_document.py +45 -0
- ruml_parser/internal/ruml/text_reference/__init__.py +2 -0
- ruml_parser/internal/ruml/text_reference/text.py +69 -0
- ruml_parser/internal/ruml/text_reference/text_reference_capability_declaration.py +25 -0
- ruml_parser/internal/ruml/text_reference/text_refs_node_capability.py +32 -0
- ruml_parser/internal/ruml/tree/__init__.py +2 -0
- ruml_parser/internal/ruml/tree/tree_capability_declarations.py +30 -0
- ruml_parser/internal/validation/__init__.py +14 -0
- ruml_parser/internal/validation/capabilities.py +227 -0
- ruml_parser/internal/validation/contexts.py +51 -0
- ruml_parser/internal/validation/datapoint_sets.py +125 -0
- ruml_parser/internal/validation/modular.py +42 -0
- ruml_parser/internal/validation/recursion.py +197 -0
- ruml_parser/internal/validation/root.py +36 -0
- ruml_parser/internal/validation/texts.py +50 -0
- ruml_parser/model/__init__.py +2 -0
- ruml_parser/model/ruml.py +1156 -0
- ruml_parser/model/ruml_result.py +430 -0
- ruml_parser/node_result_status.py +19 -0
- ruml_parser/pydantic.py +96 -0
- ruml_parser/ruml_parser.py +75 -0
- ruml_parser/schema_files.py +23 -0
- ruml_parser/schema_validation.py +354 -0
- ruml_parser/structural_error.py +36 -0
- ruml_parser/text.py +220 -0
- ruml_parser-1.0.0.dist-info/METADATA +119 -0
- ruml_parser-1.0.0.dist-info/RECORD +72 -0
- ruml_parser-1.0.0.dist-info/WHEEL +4 -0
- ruml_parser-1.0.0.dist-info/licenses/LICENSE +73 -0
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
from datetime import datetime
|
|
6
|
+
from uuid import UUID
|
|
7
|
+
|
|
8
|
+
from ruml_parser.internal.ruml.aliases import (
|
|
9
|
+
DerivationType,
|
|
10
|
+
DocumentStatus,
|
|
11
|
+
DocumentType,
|
|
12
|
+
Hash,
|
|
13
|
+
LanguageCode,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
18
|
+
class Author:
|
|
19
|
+
name: str
|
|
20
|
+
"""Name of the author"""
|
|
21
|
+
email: str | None = None
|
|
22
|
+
"""Optional email of the author"""
|
|
23
|
+
organization: str | None = None
|
|
24
|
+
"""Institutional affiliation of the author, not the document's publisher"""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
28
|
+
class DerivedFrom:
|
|
29
|
+
original_id: UUID
|
|
30
|
+
"""The id of the original document"""
|
|
31
|
+
original_hash: Hash | None = None
|
|
32
|
+
"""The hash of the original document"""
|
|
33
|
+
original_status: DocumentStatus
|
|
34
|
+
"""The status of the original at the time of copying"""
|
|
35
|
+
derivation_type: DerivationType
|
|
36
|
+
"""How this document was derived from the original"""
|
|
37
|
+
derived_at: datetime
|
|
38
|
+
"""The timestamp of the copy creation"""
|
|
39
|
+
derived_by: str | None = None
|
|
40
|
+
"""Creating entity/person"""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
44
|
+
class Metadata:
|
|
45
|
+
id: UUID
|
|
46
|
+
"""Unique identifier of the RUML file"""
|
|
47
|
+
title: str | None = None
|
|
48
|
+
"""Title of the rulemap"""
|
|
49
|
+
description: str | None = None
|
|
50
|
+
"""Description of what the rulemap represents"""
|
|
51
|
+
version: str
|
|
52
|
+
"""Content version"""
|
|
53
|
+
created: datetime
|
|
54
|
+
"""Creation timestamp"""
|
|
55
|
+
modified: datetime
|
|
56
|
+
"""Timestamp of the last modification"""
|
|
57
|
+
status: DocumentStatus
|
|
58
|
+
"""The status of the RUML file"""
|
|
59
|
+
comment: str | None = None
|
|
60
|
+
"""Free-text comment on the document, e.g. the reason for status `suspended`"""
|
|
61
|
+
document_type: DocumentType | None = None
|
|
62
|
+
"""The type of the document"""
|
|
63
|
+
authors: Sequence[Author] = field(default_factory=list)
|
|
64
|
+
"""List of authors"""
|
|
65
|
+
organization: str | None = None
|
|
66
|
+
"""Publishing organization who is institutionally responsible for the document"""
|
|
67
|
+
jurisdiction: str | None = None
|
|
68
|
+
"""Jurisdiction, e.g. `DE` or `DE-BY`"""
|
|
69
|
+
legal_domain: str | None = None
|
|
70
|
+
"""Legal domain"""
|
|
71
|
+
tags: Sequence[str] = field(default_factory=list)
|
|
72
|
+
"""Categorization/tagging"""
|
|
73
|
+
derived_from: DerivedFrom | None = None
|
|
74
|
+
"""Derivation of the document"""
|
|
75
|
+
language: LanguageCode | None = None
|
|
76
|
+
valid_from: datetime | None = None
|
|
77
|
+
"""Validity start date"""
|
|
78
|
+
valid_until: datetime | None = None
|
|
79
|
+
"""Validity end date"""
|
|
80
|
+
replaces: UUID | None = None
|
|
81
|
+
"""Reference to a replaced version"""
|
|
82
|
+
replaced_by: UUID | None = None
|
|
83
|
+
"""Reference to a successor version"""
|
|
@@ -0,0 +1,29 @@
|
|
|
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, field
|
|
5
|
+
from typing import Any
|
|
6
|
+
from uuid import UUID
|
|
7
|
+
|
|
8
|
+
from ruml_parser.internal.ruml.aliases import DecisionMode
|
|
9
|
+
from ruml_parser.internal.ruml.capability.node_capabilities import NodeCapabilities
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
13
|
+
class AbstractNode:
|
|
14
|
+
id: UUID
|
|
15
|
+
"""Unique identifier of the node"""
|
|
16
|
+
label: str
|
|
17
|
+
"""Human-readable label for the node"""
|
|
18
|
+
alt_text: str | None = None
|
|
19
|
+
"""Alternative short-form label or text for the node"""
|
|
20
|
+
description: str | None = None
|
|
21
|
+
"""Longer explanation of what the node represents (at most 10000 characters)"""
|
|
22
|
+
capabilities: NodeCapabilities = field(default_factory=NodeCapabilities)
|
|
23
|
+
"""Node-level capability values"""
|
|
24
|
+
metadata: Mapping[str, Any] = field(default_factory=dict)
|
|
25
|
+
"""Free-form, implementation-defined node metadata"""
|
|
26
|
+
decision_mode: DecisionMode | None = None
|
|
27
|
+
"""Combination mode for a leaf node with multiple decision capabilities"""
|
|
28
|
+
modular: bool | None = None
|
|
29
|
+
"""Whether the node is a reusable, self-contained module"""
|
|
@@ -0,0 +1,15 @@
|
|
|
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 LexId, Operator
|
|
7
|
+
from ruml_parser.internal.ruml.nodes.abstract_node import AbstractNode
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
11
|
+
class BranchNode(AbstractNode):
|
|
12
|
+
operator: Operator
|
|
13
|
+
"""Logical operator combining the outcomes of the child nodes"""
|
|
14
|
+
children: Sequence[LexId] = field(default_factory=list)
|
|
15
|
+
"""Ordered lexIds of the child nodes"""
|
|
@@ -0,0 +1,10 @@
|
|
|
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.nodes.abstract_node import AbstractNode
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
9
|
+
class LeafNode(AbstractNode):
|
|
10
|
+
pass
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
|
|
5
|
+
from ruml_parser.internal.ruml.aliases import (
|
|
6
|
+
CapabilityRole,
|
|
7
|
+
OfficialCapabilityId,
|
|
8
|
+
ProtocolLevel,
|
|
9
|
+
)
|
|
10
|
+
from ruml_parser.internal.ruml.capability.abstract_capability_declaration import (
|
|
11
|
+
AbstractCapabilityDeclaration,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
16
|
+
class ProtocolConfig:
|
|
17
|
+
level: ProtocolLevel = ProtocolLevel.standard
|
|
18
|
+
"""Verbosity of the recorded protocol"""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
22
|
+
class ProtocolCapabilityDeclaration(AbstractCapabilityDeclaration):
|
|
23
|
+
id = str(OfficialCapabilityId.ruml_protocol)
|
|
24
|
+
role = CapabilityRole.reaction
|
|
25
|
+
|
|
26
|
+
required: bool = False
|
|
27
|
+
"""Whether the engine must write a protocol; one that cannot must not evaluate"""
|
|
28
|
+
config: ProtocolConfig = field(default_factory=ProtocolConfig)
|
|
29
|
+
"""Configuration of the protocol to record"""
|
|
@@ -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 QueryCapabilityDeclaration(AbstractCapabilityDeclaration):
|
|
15
|
+
"""Root-level declaration of `ruml:query` (`PlainPayload`)."""
|
|
16
|
+
|
|
17
|
+
id = str(OfficialCapabilityId.ruml_query)
|
|
18
|
+
role = CapabilityRole.decision
|
|
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,17 @@
|
|
|
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 OfficialCapabilityId
|
|
6
|
+
from ruml_parser.internal.ruml.capability.abstract_node_capability import (
|
|
7
|
+
AbstractNodeCapability,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
12
|
+
class QueryNodeCapability(AbstractNodeCapability):
|
|
13
|
+
id = str(OfficialCapabilityId.ruml_query)
|
|
14
|
+
expression: str
|
|
15
|
+
"""JSONata expression computing the node's truth value"""
|
|
16
|
+
description: str | None = None
|
|
17
|
+
"""Optional explanation of what the expression evaluates"""
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
from collections.abc import Iterable, Mapping
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
|
|
6
|
+
from ruml_parser.internal.ruml.aliases import LexId
|
|
7
|
+
from ruml_parser.internal.ruml.capability.capability_declarations import (
|
|
8
|
+
CapabilityDeclarations,
|
|
9
|
+
)
|
|
10
|
+
from ruml_parser.internal.ruml.capability.node_capabilities import NodeCapability
|
|
11
|
+
from ruml_parser.internal.ruml.metadata import Metadata
|
|
12
|
+
from ruml_parser.internal.ruml.nodes.node import Node
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
16
|
+
class RumlDocument:
|
|
17
|
+
"""A RUML file.
|
|
18
|
+
|
|
19
|
+
The `$format` discriminator is dropped (it is a constant, and this class already
|
|
20
|
+
says what the object is), and the `rulemap` wrapper object, whose only content is
|
|
21
|
+
`nodes`, is flattened into `nodes`.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
spec_version: str
|
|
25
|
+
"""RUML spec version the file conforms to"""
|
|
26
|
+
metadata: Metadata
|
|
27
|
+
"""Metadata about the RUML file itself"""
|
|
28
|
+
capabilities: CapabilityDeclarations = field(default_factory=CapabilityDeclarations)
|
|
29
|
+
"""Root-level capability declarations.
|
|
30
|
+
|
|
31
|
+
As per spec chapter 4.3, these are required for capabilities that are used at the
|
|
32
|
+
node level (rule CAP-15).
|
|
33
|
+
"""
|
|
34
|
+
nodes: Mapping[LexId, Node]
|
|
35
|
+
"""The decision logic tree: the rulemap nodes, keyed by lexId"""
|
|
36
|
+
|
|
37
|
+
def all_node_capabilities_of_type[T: NodeCapability](
|
|
38
|
+
self, capability_type: type[T]
|
|
39
|
+
) -> Iterable[tuple[LexId, T]]:
|
|
40
|
+
"""
|
|
41
|
+
Return all capabilities of type ``capability_type`` from all nodes
|
|
42
|
+
"""
|
|
43
|
+
for lex_id, node in self.nodes.items():
|
|
44
|
+
for capability in node.capabilities.all_of_type(capability_type):
|
|
45
|
+
yield (lex_id, capability)
|
|
@@ -0,0 +1,69 @@
|
|
|
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 datetime import datetime
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from ruml_parser.internal.ruml.aliases import (
|
|
9
|
+
Hash,
|
|
10
|
+
LanguageCode,
|
|
11
|
+
LegislativeStatus,
|
|
12
|
+
TextType,
|
|
13
|
+
)
|
|
14
|
+
from ruml_parser.model import ruml as model
|
|
15
|
+
from ruml_parser.text import text_of
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
19
|
+
class TextSource:
|
|
20
|
+
uri: str
|
|
21
|
+
"""URI of the source document a text's content was imported from"""
|
|
22
|
+
digest: Hash | None = None
|
|
23
|
+
"""Digest of the archived source document"""
|
|
24
|
+
terms: str | None = None
|
|
25
|
+
"""URI of the source's reuse terms"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
29
|
+
class Text:
|
|
30
|
+
title: str
|
|
31
|
+
"""Human-readable title of the text"""
|
|
32
|
+
timestamp: datetime
|
|
33
|
+
"""When the author retrieved and recorded this text"""
|
|
34
|
+
uri: str | None = None
|
|
35
|
+
"""URI of the text as published by its source; none for texts written in the
|
|
36
|
+
RUML file itself"""
|
|
37
|
+
status: LegislativeStatus | None = None
|
|
38
|
+
"""Legislative status of the text"""
|
|
39
|
+
type: TextType = model.Type2.embedded
|
|
40
|
+
"""How the text content is carried"""
|
|
41
|
+
text: str | None = None
|
|
42
|
+
"""Plain text; an embedded text carries this or `content`"""
|
|
43
|
+
content: Mapping[str, Any] | None = None
|
|
44
|
+
"""Structured text in RUML Text form (§4.12), as JSON"""
|
|
45
|
+
digest: Hash | None = None
|
|
46
|
+
"""SHA3-256 over the RFC 8785 form of `content`"""
|
|
47
|
+
source: TextSource | None = None
|
|
48
|
+
"""The source document `content` was imported from"""
|
|
49
|
+
url: str | None = None
|
|
50
|
+
"""URL of the text; required for type 'url'"""
|
|
51
|
+
container_path: str | None = None
|
|
52
|
+
"""Path to the text inside the RUML container (below `.texts/`); required for
|
|
53
|
+
type 'container'"""
|
|
54
|
+
ref: str | None = None
|
|
55
|
+
"""Symbolic reference; required for type 'external'"""
|
|
56
|
+
version: str | None = None
|
|
57
|
+
"""Version of the text"""
|
|
58
|
+
valid_from: datetime | None = None
|
|
59
|
+
"""Validity start date"""
|
|
60
|
+
valid_until: datetime | None = None
|
|
61
|
+
"""Validity end date"""
|
|
62
|
+
language: LanguageCode | None = None
|
|
63
|
+
is_referenced: bool = True
|
|
64
|
+
"""Whether the text is referenced by at least one node"""
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def plain_text(self) -> str | None:
|
|
68
|
+
"""The readable text of `content`, else `text`, else none."""
|
|
69
|
+
return self.text if self.content is None else text_of(self.content)
|
|
@@ -0,0 +1,25 @@
|
|
|
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, field
|
|
5
|
+
|
|
6
|
+
from ruml_parser.internal.ruml.aliases import (
|
|
7
|
+
CapabilityRole,
|
|
8
|
+
OfficialCapabilityId,
|
|
9
|
+
TextId,
|
|
10
|
+
)
|
|
11
|
+
from ruml_parser.internal.ruml.capability.abstract_capability_declaration import (
|
|
12
|
+
AbstractCapabilityDeclaration,
|
|
13
|
+
)
|
|
14
|
+
from ruml_parser.internal.ruml.text_reference.text import Text
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
18
|
+
class TextReferenceCapabilityDeclaration(AbstractCapabilityDeclaration):
|
|
19
|
+
id = str(OfficialCapabilityId.ruml_text_reference)
|
|
20
|
+
role = CapabilityRole.data
|
|
21
|
+
|
|
22
|
+
required: bool = False
|
|
23
|
+
"""Whether this capability must be resolved to evaluate"""
|
|
24
|
+
data: Mapping[TextId, Text] = field(default_factory=dict)
|
|
25
|
+
"""Text definitions, keyed by text id"""
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
5
|
+
|
|
6
|
+
from ruml_parser.internal.ruml.aliases import (
|
|
7
|
+
OfficialCapabilityId,
|
|
8
|
+
TextAnchorType,
|
|
9
|
+
TextId,
|
|
10
|
+
)
|
|
11
|
+
from ruml_parser.internal.ruml.capability.abstract_node_capability import (
|
|
12
|
+
AbstractNodeCapability,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
17
|
+
class TextAnchor:
|
|
18
|
+
id: TextId
|
|
19
|
+
"""Key of the text entry in this RUML's own data"""
|
|
20
|
+
type: TextAnchorType
|
|
21
|
+
"""`represents`: the norm the node implements; `refers-to`: a text it refers to"""
|
|
22
|
+
element: str | None = None
|
|
23
|
+
"""GUID of an element of the entry's RUML Text; none for the whole text"""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
27
|
+
class TextRefsNodeCapability(AbstractNodeCapability):
|
|
28
|
+
"""The texts a node is linked to (§4.12); at most one anchor `represents`."""
|
|
29
|
+
|
|
30
|
+
id = str(OfficialCapabilityId.ruml_text_reference)
|
|
31
|
+
|
|
32
|
+
refs: Sequence[TextAnchor]
|
|
@@ -0,0 +1,30 @@
|
|
|
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 TreeReferenceCapabilityDeclaration(AbstractCapabilityDeclaration):
|
|
13
|
+
"""Root-level declaration of `ruml:tree-reference`, which has no payload (TREE-01)."""
|
|
14
|
+
|
|
15
|
+
id = str(OfficialCapabilityId.ruml_tree_reference)
|
|
16
|
+
role = CapabilityRole.data
|
|
17
|
+
|
|
18
|
+
required: bool = False
|
|
19
|
+
"""Whether this capability must be resolved to evaluate"""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
23
|
+
class TreeIncludeCapabilityDeclaration(AbstractCapabilityDeclaration):
|
|
24
|
+
"""Root-level declaration of `ruml:tree-include`, which has no payload (TREE-01)."""
|
|
25
|
+
|
|
26
|
+
id = str(OfficialCapabilityId.ruml_tree_include)
|
|
27
|
+
role = CapabilityRole.decision
|
|
28
|
+
|
|
29
|
+
required: bool = False
|
|
30
|
+
"""Whether this capability must be resolved to evaluate"""
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""Additional validations to apply while building internal model instances.
|
|
4
|
+
|
|
5
|
+
For now, contains the spec's cross-object rules: The schema validates one object at a
|
|
6
|
+
time and the dataclasses carry no validation, so a rule that relates different parts of
|
|
7
|
+
a document (e.g. a node's capability ids to the root's declarations) is checked here
|
|
8
|
+
instead, one module per rule (or family of rules).
|
|
9
|
+
Most of them raise, and `ruml_parser.internal.mapping.to_internal` is meant to run those
|
|
10
|
+
on the document it has just built, so that a `RumlDocument` obtained from it satisfies
|
|
11
|
+
them. `recursion` is the partial exception: §6.4 asks an implementation to *warn* about
|
|
12
|
+
some of what it finds rather than reject the document, so its validation logs those
|
|
13
|
+
findings as warnings and raises only for the chapter's `MUST`/`MUST NOT` rules.
|
|
14
|
+
"""
|