semops-system 0.29.0.dev1__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.
@@ -0,0 +1,28 @@
1
+ # Build output. Each engine directory keeps its own .gitignore for what is particular to it
2
+ # (HOLOS's fetched test suites and RocksDB leftovers, for instance); this covers the root.
3
+ /target/
4
+ **/target/
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ .pytest_cache/
10
+ .venv/
11
+ dist/
12
+ *.egg-info/
13
+
14
+ # Node
15
+ node_modules/
16
+
17
+ # Editors and operating systems
18
+ .vscode/
19
+ .idea/
20
+ *.swp
21
+ .DS_Store
22
+ Thumbs.db
23
+ desktop.ini
24
+
25
+ # Local configuration and secrets
26
+ *.env.local
27
+ .env
28
+ .env.*
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Peter Winstanley
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pwin (Peter Winstanley)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.5
2
+ Name: semops-system
3
+ Version: 0.29.0.dev1
4
+ Summary: SemOps System: RDF 1.2, SPARQL 1.2, SHACL and GeoSPARQL (HOLOS), the SHACL engine and tarka, as one install
5
+ Project-URL: Homepage, https://github.com/pwin/SemopsSystem
6
+ Project-URL: Repository, https://github.com/pwin/SemopsSystem
7
+ Project-URL: Issues, https://github.com/pwin/SemopsSystem/issues
8
+ Author: Peter Winstanley
9
+ License-Expression: MIT OR Apache-2.0
10
+ License-File: LICENSE-APACHE
11
+ License-File: LICENSE-MIT
12
+ Keywords: geosparql,ottr,rdf,rdf-1.2,semantic-web,shacl,sparql,tarql,triplestore
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: Implementation :: CPython
17
+ Classifier: Topic :: Database :: Database Engines/Servers
18
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: holosdb==0.27.0
21
+ Requires-Dist: shacl==0.3.9
22
+ Requires-Dist: tarka-rdf==0.3.1
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest>=8; extra == 'test'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # semops-system
28
+
29
+ SemOps System as one Python install: the HOLOS RDF 1.2 store and SPARQL 1.2 engine (with
30
+ GeoSPARQL, SHACL and the `fn:`, `afn:` and `spif:` function libraries), the SHACL engine, and
31
+ tarka for mapping tables to RDF.
32
+
33
+ ```sh
34
+ pip install semops-system
35
+ ```
36
+
37
+ ```python
38
+ import semops_system as so
39
+
40
+ store = so.holos.Store() # in memory; Store("path") persists to disk
41
+ store.update("""
42
+ PREFIX ex: <http://example.org/>
43
+ INSERT DATA { ex:alice ex:age 42 {| ex:source ex:census |} }
44
+ """)
45
+ store.query("ASK { ?r <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> ?t }") # True
46
+
47
+ report = so.shacl.Shapes.from_file("shapes.ttl").validate_file("data.ttl")
48
+ report.conforms
49
+
50
+ mapping = so.tarka.Mapping.tarql_file("people.tarql")
51
+ mapping.triplify(polars_frame)
52
+ ```
53
+
54
+ `so.holos`, `so.shacl` and `so.tarka` are the `holosdb`, `shacl` and `tarka_rdf` modules, so
55
+ their documentation applies as it stands:
56
+ [HOLOS](https://github.com/pwin/SemopsSystem/tree/main/holos/crates/holos-python),
57
+ [SHACL engine](https://github.com/pwin/SemopsSystem/tree/main/shacl/crates/shacl-python),
58
+ [tarka](https://github.com/pwin/SemopsSystem/tree/main/tarka/crates/tarka-python).
59
+
60
+ ## This release
61
+
62
+ 0.29.0.dev1 is a bridge. It pins the engine releases that agree with each other
63
+ (holosdb 0.27.0, shacl 0.3.9, tarka-rdf 0.3.1; `semops_system.ENGINES` says which are
64
+ installed), so a project needs one pin instead of three. A later release replaces it with
65
+ one native wheel built from the SemOps System workspace, under the same names.
66
+
67
+ tarka produces RDF 1.1. To get RDF 1.2 from its output, load it into a store and run SPARQL
68
+ 1.2. For example, this annotates every mapped triple with its source:
69
+
70
+ ```sparql
71
+ INSERT { ?s ?p ?o {| ex:source ex:spreadsheet |} } WHERE { ?s ?p ?o }
72
+ ```
73
+
74
+ Licence: MIT OR Apache-2.0.
@@ -0,0 +1,48 @@
1
+ # semops-system
2
+
3
+ SemOps System as one Python install: the HOLOS RDF 1.2 store and SPARQL 1.2 engine (with
4
+ GeoSPARQL, SHACL and the `fn:`, `afn:` and `spif:` function libraries), the SHACL engine, and
5
+ tarka for mapping tables to RDF.
6
+
7
+ ```sh
8
+ pip install semops-system
9
+ ```
10
+
11
+ ```python
12
+ import semops_system as so
13
+
14
+ store = so.holos.Store() # in memory; Store("path") persists to disk
15
+ store.update("""
16
+ PREFIX ex: <http://example.org/>
17
+ INSERT DATA { ex:alice ex:age 42 {| ex:source ex:census |} }
18
+ """)
19
+ store.query("ASK { ?r <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> ?t }") # True
20
+
21
+ report = so.shacl.Shapes.from_file("shapes.ttl").validate_file("data.ttl")
22
+ report.conforms
23
+
24
+ mapping = so.tarka.Mapping.tarql_file("people.tarql")
25
+ mapping.triplify(polars_frame)
26
+ ```
27
+
28
+ `so.holos`, `so.shacl` and `so.tarka` are the `holosdb`, `shacl` and `tarka_rdf` modules, so
29
+ their documentation applies as it stands:
30
+ [HOLOS](https://github.com/pwin/SemopsSystem/tree/main/holos/crates/holos-python),
31
+ [SHACL engine](https://github.com/pwin/SemopsSystem/tree/main/shacl/crates/shacl-python),
32
+ [tarka](https://github.com/pwin/SemopsSystem/tree/main/tarka/crates/tarka-python).
33
+
34
+ ## This release
35
+
36
+ 0.29.0.dev1 is a bridge. It pins the engine releases that agree with each other
37
+ (holosdb 0.27.0, shacl 0.3.9, tarka-rdf 0.3.1; `semops_system.ENGINES` says which are
38
+ installed), so a project needs one pin instead of three. A later release replaces it with
39
+ one native wheel built from the SemOps System workspace, under the same names.
40
+
41
+ tarka produces RDF 1.1. To get RDF 1.2 from its output, load it into a store and run SPARQL
42
+ 1.2. For example, this annotates every mapped triple with its source:
43
+
44
+ ```sparql
45
+ INSERT { ?s ?p ?o {| ex:source ex:spreadsheet |} } WHERE { ?s ?p ?o }
46
+ ```
47
+
48
+ Licence: MIT OR Apache-2.0.
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.26"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "semops-system"
7
+ # A bridge release, ahead of the workspace's own native wheel (roadmap phase 3). It installs
8
+ # the engine releases that belong together, as versions.toml lists them, and presents them as
9
+ # one package: `semops_system.holos`, `.shacl` and `.tarka`. The native wheel will keep those
10
+ # names, so code written against this release keeps working when it replaces it.
11
+ version = "0.29.0.dev1"
12
+ description = "SemOps System: RDF 1.2, SPARQL 1.2, SHACL and GeoSPARQL (HOLOS), the SHACL engine and tarka, as one install"
13
+ readme = "README.md"
14
+ requires-python = ">=3.11"
15
+ license = "MIT OR Apache-2.0"
16
+ license-files = ["LICENSE-MIT", "LICENSE-APACHE"]
17
+ authors = [{ name = "Peter Winstanley" }]
18
+ keywords = ["rdf", "rdf-1.2", "sparql", "shacl", "geosparql", "triplestore", "tarql", "ottr", "semantic-web"]
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Intended Audience :: Developers",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ "Programming Language :: Python :: Implementation :: CPython",
24
+ "Topic :: Database :: Database Engines/Servers",
25
+ "Topic :: Scientific/Engineering :: Information Analysis",
26
+ ]
27
+ # Exact pins: the point of this package is that these three are the ones that agree.
28
+ # Kept equal to versions.toml by tests/test_versions.py.
29
+ dependencies = [
30
+ "holosdb==0.27.0",
31
+ "shacl==0.3.9",
32
+ "tarka-rdf==0.3.1",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ test = ["pytest>=8"]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/pwin/SemopsSystem"
40
+ Repository = "https://github.com/pwin/SemopsSystem"
41
+ Issues = "https://github.com/pwin/SemopsSystem/issues"
42
+
43
+ [tool.hatch.build.targets.wheel]
44
+ packages = ["src/semops_system"]
@@ -0,0 +1,41 @@
1
+ """SemOps System: the pwin RDF toolchain as one Python package.
2
+
3
+ import semops_system as so
4
+
5
+ store = so.holos.Store() # RDF 1.2 store, SPARQL 1.2, GeoSPARQL, SHACL
6
+ shapes = so.shacl.Shapes.from_turtle(...) # the SHACL engine on its own
7
+ mapping = so.tarka.Mapping.tarql(...) # tabular data to RDF 1.1
8
+
9
+ `holos`, `shacl` and `tarka` are the `holosdb`, `shacl` and `tarka_rdf` modules themselves,
10
+ not copies, so their documentation applies unchanged and objects pass freely between code
11
+ that imports either name. `from semops_system.holos import Store` works too.
12
+
13
+ This release installs the engine releases listed in `ENGINES`, which are the ones that
14
+ agree with each other. The native wheel that replaces it keeps these names.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import sys
20
+ from importlib.metadata import version as _version
21
+
22
+ import holosdb as holos
23
+ import shacl
24
+ import tarka_rdf as tarka
25
+
26
+ __version__ = _version("semops-system")
27
+
28
+ #: The engine release each part of the package comes from.
29
+ ENGINES: dict[str, str] = {
30
+ "holosdb": _version("holosdb"),
31
+ "shacl": _version("shacl"),
32
+ "tarka-rdf": _version("tarka-rdf"),
33
+ }
34
+
35
+ # Registered as submodules, so `import semops_system.holos` and
36
+ # `from semops_system.shacl import Shapes` work as well as attribute access.
37
+ for _name, _module in (("holos", holos), ("shacl", shacl), ("tarka", tarka)):
38
+ sys.modules[f"{__name__}.{_name}"] = _module
39
+ del _name, _module
40
+
41
+ __all__ = ["ENGINES", "__version__", "holos", "shacl", "tarka"]
@@ -0,0 +1,218 @@
1
+ """The capability floor (docs/decisions/0003), as checks a release must pass.
2
+
3
+ Each test exercises one thing SemOps System must do through the package's own names:
4
+ RDF 1.2, SPARQL 1.2, SEP-0002 dates, GeoSPARQL, the extension function libraries, SHACL
5
+ through both the store and the standalone engine, and tarka mapping, including the
6
+ SPARQL 1.2 step that lifts tarka's RDF 1.1 output to RDF 1.2.
7
+ """
8
+
9
+ import polars as pl
10
+ import pytest
11
+
12
+ import semops_system as so
13
+ from semops_system.holos import Store
14
+
15
+ EX = "http://example.org/"
16
+ PREFIXES = f"""
17
+ PREFIX ex: <{EX}>
18
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
19
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
20
+ PREFIX geo: <http://www.opengis.net/ont/geosparql#>
21
+ PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
22
+ PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
23
+ PREFIX afn: <http://jena.apache.org/ARQ/function#>
24
+ PREFIX spif: <http://spinrdf.org/spif#>
25
+ PREFIX sh: <http://www.w3.org/ns/shacl#>
26
+ """
27
+
28
+
29
+ def ask(store: Store, where: str) -> bool:
30
+ result = store.query(PREFIXES + f"ASK {{ {where} }}")
31
+ assert isinstance(result, bool)
32
+ return result
33
+
34
+
35
+ def one(store: Store, select: str, var: str):
36
+ rows = store.query(PREFIXES + select)
37
+ assert len(rows) == 1, rows
38
+ return rows[0].term(var)
39
+
40
+
41
+ def test_submodules_are_the_engines_themselves():
42
+ import holosdb
43
+ import shacl
44
+ import tarka_rdf
45
+
46
+ assert so.holos is holosdb and so.shacl is shacl and so.tarka is tarka_rdf
47
+
48
+
49
+ def test_persistent_store_is_compiled_in():
50
+ assert so.holos.has_rocksdb()
51
+
52
+
53
+ # ---------------------------------------------------------------- RDF 1.2 and SPARQL 1.2
54
+
55
+
56
+ def test_rdf12_triple_terms_and_annotations():
57
+ store = Store()
58
+ store.update(PREFIXES + 'INSERT DATA { ex:alice ex:age 42 {| ex:source ex:census |} }')
59
+ # The annotation reifies the asserted triple: a reifier with rdf:reifies <<( … )>>.
60
+ assert ask(store, "ex:alice ex:age 42 . ?r rdf:reifies <<( ex:alice ex:age 42 )>> ; ex:source ex:census")
61
+
62
+
63
+ def test_sparql12_triple_functions():
64
+ store = Store()
65
+ store.update(PREFIXES + "INSERT DATA { ex:r rdf:reifies <<( ex:a ex:p ex:b )>> }")
66
+ assert one(store, "SELECT ?s WHERE { ?r rdf:reifies ?t FILTER(isTRIPLE(?t)) BIND(SUBJECT(?t) AS ?s) }", "s") == f"<{EX}a>"
67
+
68
+
69
+ def test_sep0002_dates_compare_by_value():
70
+ assert ask(Store(), 'FILTER("2024-01-31"^^xsd:date < "2024-11-04"^^xsd:date)')
71
+ assert ask(Store(), 'FILTER("2024-01-31T00:00:00Z"^^xsd:dateTime + "P1M"^^xsd:yearMonthDuration > "2024-02-01T00:00:00Z"^^xsd:dateTime)')
72
+
73
+
74
+ # ---------------------------------------------------------------- GeoSPARQL
75
+
76
+
77
+ def test_geosparql_functions_are_present():
78
+ names = so.holos.geosparql_functions()
79
+ assert any(n.endswith("sfWithin") for n in names)
80
+ assert any(n.endswith("buffer") for n in names)
81
+
82
+
83
+ def test_geosparql_topology_and_distance():
84
+ store = Store()
85
+ assert ask(store, 'FILTER(geof:sfWithin("POINT(1 1)"^^geo:wktLiteral, "POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))"^^geo:wktLiteral))')
86
+ assert not ask(store, 'FILTER(geof:sfWithin("POINT(3 3)"^^geo:wktLiteral, "POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))"^^geo:wktLiteral))')
87
+
88
+
89
+ # ---------------------------------------------------------------- extension functions
90
+
91
+
92
+ @pytest.mark.parametrize(
93
+ ("expr", "expected"),
94
+ [
95
+ ('fn:upper-case("semops")', '"SEMOPS"'),
96
+ ('fn:substring-before("tarka-rdf", "-")', '"tarka"'),
97
+ ("afn:localname(<http://example.org/thing>)", '"thing"'),
98
+ ('spif:titleCase("semops system")', '"Semops System"'),
99
+ ('spif:buildString("{?1}-{?2}", "a", "b")', '"a-b"'),
100
+ ],
101
+ )
102
+ def test_extension_functions_in_store_queries(expr, expected):
103
+ assert one(Store(), f"SELECT ?v WHERE {{ BIND({expr} AS ?v) }}", "v") == expected
104
+
105
+
106
+ # ---------------------------------------------------------------- SHACL
107
+
108
+ SHAPES = f"""
109
+ @prefix sh: <http://www.w3.org/ns/shacl#> .
110
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
111
+ @prefix ex: <{EX}> .
112
+ ex:PersonShape a sh:NodeShape ;
113
+ sh:targetClass ex:Person ;
114
+ sh:property [ sh:path ex:age ; sh:datatype xsd:integer ; sh:maxCount 1 ] ;
115
+ sh:sparql [
116
+ sh:message "an adult must be 18 or over" ;
117
+ sh:select "SELECT $this WHERE {{ $this <{EX}adult> true ; <{EX}age> ?a FILTER(?a < 18) }}"
118
+ ] .
119
+ """
120
+ DATA_BAD = f"""
121
+ @prefix ex: <{EX}> .
122
+ ex:bob a ex:Person ; ex:age 12 ; ex:adult true .
123
+ """
124
+ DATA_GOOD = f"""
125
+ @prefix ex: <{EX}> .
126
+ ex:carol a ex:Person ; ex:age 40 ; ex:adult true .
127
+ """
128
+
129
+
130
+ def test_shacl_engine_core_and_sparql_constraints():
131
+ shapes = so.shacl.Shapes.from_turtle(SHAPES)
132
+ assert shapes.validate_turtle(DATA_GOOD).conforms
133
+ report = shapes.validate_turtle(DATA_BAD)
134
+ assert not report.conforms
135
+ assert len(report.results) == 1
136
+
137
+
138
+ def store_with(tmp_path, data: str) -> Store:
139
+ path = tmp_path / "data.ttl"
140
+ path.write_text(data, encoding="utf-8")
141
+ store = Store()
142
+ store.load(str(path))
143
+ return store
144
+
145
+
146
+ def shapes_file(tmp_path, text: str) -> str:
147
+ path = tmp_path / "shapes.ttl"
148
+ path.write_text(text, encoding="utf-8")
149
+ return str(path)
150
+
151
+
152
+ CORE_SHAPES = SHAPES.split(" sh:sparql [")[0].rstrip().rstrip(";") + " .\n"
153
+ DATA_TWO_AGES = f"""
154
+ @prefix ex: <{EX}> .
155
+ ex:dave a ex:Person ; ex:age 30, 31 .
156
+ """
157
+
158
+
159
+ @pytest.mark.parametrize("engine", ["native", "adapted"])
160
+ def test_store_validates_core_with_both_validators(engine, tmp_path):
161
+ store = store_with(tmp_path, DATA_TWO_AGES)
162
+ result = store.validate(shapes_file(tmp_path, CORE_SHAPES), engine=engine)
163
+ assert result["conforms"] is False
164
+ assert result["violations"] == 1 # sh:maxCount 1
165
+
166
+
167
+ def test_store_validates_shacl_sparql_with_the_adapted_validator(tmp_path):
168
+ store = store_with(tmp_path, DATA_BAD)
169
+ result = store.validate(shapes_file(tmp_path, SHAPES), engine="adapted")
170
+ assert result["conforms"] is False
171
+ assert result["violations"] == 1
172
+
173
+
174
+ def test_native_validator_refuses_shacl_sparql_rather_than_passing_it(tmp_path):
175
+ """HOLOS 0.27.0's native, incremental validator has no SHACL-SPARQL. It fails closed:
176
+ it refuses the shapes rather than report a conforming graph. One validator covering
177
+ both is phase 4 work (docs/decisions/0003)."""
178
+ store = store_with(tmp_path, DATA_BAD)
179
+ with pytest.raises(so.holos.HolosError, match="sh:sparql"):
180
+ store.validate(shapes_file(tmp_path, SHAPES), engine="native")
181
+
182
+
183
+ # ---------------------------------------------------------------- tarka, and the RDF 1.2 lift
184
+
185
+ TARQL = f"""
186
+ PREFIX ex: <{EX}>
187
+ PREFIX apf: <http://jena.apache.org/ARQ/property#>
188
+ CONSTRUCT {{ ?person ex:tag ?tag }}
189
+ WHERE {{
190
+ BIND(IRI(CONCAT("{EX}", ?id)) AS ?person)
191
+ ?tag apf:strSplit (?tags ";")
192
+ }}
193
+ """
194
+
195
+
196
+ def tarka_output() -> pl.DataFrame:
197
+ frame = pl.DataFrame({"id": ["alice", "bob"], "tags": ["red;blue", "green"]})
198
+ return so.tarka.Mapping.tarql(TARQL).triplify(frame)
199
+
200
+
201
+ def test_tarka_maps_with_apf_property_functions():
202
+ triples = tarka_output()
203
+ assert triples.height == 3
204
+ assert set(triples["object"]) == {'"red"', '"blue"', '"green"'}
205
+
206
+
207
+ def test_sparql12_lifts_tarka_output_to_rdf12():
208
+ """tarka stays RDF 1.1; a SPARQL 1.2 update in the engine builds the RDF 1.2."""
209
+ store = Store()
210
+ lines = " ".join(f"{s} {p} {o} ." for s, p, o in tarka_output().iter_rows())
211
+ store.update(f"INSERT DATA {{ {lines} }}")
212
+ # Annotate every mapped tag with where it came from: each asserted triple gets a reifier.
213
+ store.update(
214
+ PREFIXES
215
+ + "INSERT { ?s ex:tag ?t {| ex:source ex:spreadsheet |} } WHERE { ?s ex:tag ?t }"
216
+ )
217
+ rows = store.query(PREFIXES + "SELECT ?r WHERE { ?r rdf:reifies <<( ?s ex:tag ?t )>> ; ex:source ex:spreadsheet }")
218
+ assert len(rows) == 3
@@ -0,0 +1,28 @@
1
+ """The package installs exactly the engine releases versions.toml says belong together."""
2
+
3
+ import tomllib
4
+ from importlib.metadata import requires
5
+ from pathlib import Path
6
+
7
+ import semops_system
8
+
9
+ VERSIONS = Path(__file__).resolve().parents[3] / "versions.toml"
10
+
11
+
12
+ def pinned_in_versions_toml() -> dict[str, str]:
13
+ pins = tomllib.loads(VERSIONS.read_text(encoding="utf-8"))
14
+ return {dist: engine["version"] for engine in pins["engines"].values() for dist in engine.get("pypi", [])}
15
+
16
+
17
+ def test_dependencies_are_the_versions_toml_pins():
18
+ declared = {}
19
+ for req in requires("semops-system") or []:
20
+ if "extra ==" in req:
21
+ continue
22
+ name, _, version = req.partition("==")
23
+ declared[name.strip()] = version.strip()
24
+ assert declared == pinned_in_versions_toml()
25
+
26
+
27
+ def test_installed_engines_are_the_pinned_ones():
28
+ assert semops_system.ENGINES == pinned_in_versions_toml()