cjm-capability-graph-sqlite 0.0.26__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.
- cjm_capability_graph_sqlite/__init__.py +1 -0
- cjm_capability_graph_sqlite/capability.py +849 -0
- cjm_capability_graph_sqlite/query_translation.py +313 -0
- cjm_capability_graph_sqlite-0.0.26.dist-info/METADATA +50 -0
- cjm_capability_graph_sqlite-0.0.26.dist-info/RECORD +8 -0
- cjm_capability_graph_sqlite-0.0.26.dist-info/WHEEL +5 -0
- cjm_capability_graph_sqlite-0.0.26.dist-info/licenses/LICENSE +201 -0
- cjm_capability_graph_sqlite-0.0.26.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"""The per-backend translation of the typed query expressions (pass-2 Thread 5; stage 4): NodeQuery/EdgeQuery -> parameterized SQLite SQL over the nodes/edges schema. THIS module is what makes the typed surface portable - the expression is domain- and backend-neutral; every backend tool owns a translation like this one (the ratified stage-4 split: backend owns translation; the adapter stays generic). Pure functions, unit-tested against an in-memory DB with the production schema - no capability runtime needed.
|
|
2
|
+
|
|
3
|
+
Translation rules:
|
|
4
|
+
|
|
5
|
+
- **Predicates** compile to `json_extract(properties, $.<path>)` comparisons
|
|
6
|
+
with bound parameters (values NEVER interpolated). Property paths are dotted
|
|
7
|
+
(`payload.document_id`) and validated against `[A-Za-z0-9_]` segments —
|
|
8
|
+
paths are interpolated into the JSON-path literal, so validation is the
|
|
9
|
+
injection guard for the path position.
|
|
10
|
+
- **`contains` is case-INSENSITIVE by definition** (P12): `lower(col) LIKE ...
|
|
11
|
+
ESCAPE` with `%`/`_`/`\\` escaped in the value. Both sides use SQLite
|
|
12
|
+
`lower()` (ASCII-range folding) — consistent, but non-ASCII case folding is
|
|
13
|
+
NOT performed (recorded; a unicode-folding consumer would be the promotion
|
|
14
|
+
evidence).
|
|
15
|
+
- **Id lists** bind as ONE JSON-array parameter via `json_each(?)` — no SQL
|
|
16
|
+
parameter-count limits at corpus scale (13k+ ids).
|
|
17
|
+
- **Relation / endpoint constraints** compile to correlated `EXISTS`
|
|
18
|
+
subqueries (never JOINs) — no row multiplication, so `count` needs no
|
|
19
|
+
DISTINCT and rows need no GROUP BY.
|
|
20
|
+
- **`SourcePredicate`** translates content-hash-primary (`json_each(sources)`);
|
|
21
|
+
a locator constraint raises (unsupported — use `find_nodes_by_source`, which
|
|
22
|
+
does Python-side locator equality; a recurring need here is promotion
|
|
23
|
+
evidence).
|
|
24
|
+
- **Modes**: `count` > `project` > full (mirrors the result DTO contract).
|
|
25
|
+
Projected node rows always carry `id` (+ `label` projectable structurally;
|
|
26
|
+
`sources` projectable as parsed ref dicts); edge rows always carry
|
|
27
|
+
`id`/`source_id`/`target_id` (+ `relation_type` projectable)."""
|
|
28
|
+
|
|
29
|
+
import json
|
|
30
|
+
import re
|
|
31
|
+
from typing import Any, List, Optional, Tuple
|
|
32
|
+
|
|
33
|
+
from cjm_context_graph_primitives.query import (EdgeQuery, NodeQuery, PropertyPredicate,
|
|
34
|
+
RelationPredicate, SourcePredicate)
|
|
35
|
+
from cjm_substrate.core.errors import CapabilityInputError
|
|
36
|
+
|
|
37
|
+
_PROP_PATH_RE = re.compile(r"^[A-Za-z0-9_]+(\.[A-Za-z0-9_]+)*$") # Dotted-path guard (paths are interpolated; values are bound)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _json_path(
|
|
41
|
+
prop: str, # Property name or dotted path (e.g. "payload.document_id")
|
|
42
|
+
) -> str: # SQL string literal for json_extract's path argument
|
|
43
|
+
"""Validate a dotted property path and render the JSON-path literal."""
|
|
44
|
+
if not _PROP_PATH_RE.match(prop or ""):
|
|
45
|
+
raise CapabilityInputError(
|
|
46
|
+
f"Invalid property path {prop!r} (segments must be [A-Za-z0-9_])",
|
|
47
|
+
fields_invalid=["prop"],
|
|
48
|
+
)
|
|
49
|
+
return "'$." + prop + "'"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _escape_like(
|
|
53
|
+
value: str, # Raw substring the caller wants matched literally
|
|
54
|
+
) -> str: # Value with LIKE wildcards escaped (ESCAPE '\\')
|
|
55
|
+
"""Escape `%` / `_` / `\\` so `contains` matches literally, never as wildcards."""
|
|
56
|
+
return value.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _predicate_sql(
|
|
60
|
+
pred: PropertyPredicate, # One typed property predicate
|
|
61
|
+
props_col: str, # SQL expression for the properties JSON column (e.g. "n.properties")
|
|
62
|
+
) -> Tuple[str, List[Any]]: # (SQL fragment, bound params)
|
|
63
|
+
"""Compile one property predicate to a parameterized SQL fragment."""
|
|
64
|
+
col = f"json_extract({props_col}, {_json_path(pred.prop)})"
|
|
65
|
+
op = pred.op
|
|
66
|
+
if op == "eq":
|
|
67
|
+
return f"{col} = ?", [pred.value]
|
|
68
|
+
if op == "ne":
|
|
69
|
+
return f"{col} != ?", [pred.value]
|
|
70
|
+
if op == "lt":
|
|
71
|
+
return f"{col} < ?", [pred.value]
|
|
72
|
+
if op == "le":
|
|
73
|
+
return f"{col} <= ?", [pred.value]
|
|
74
|
+
if op == "gt":
|
|
75
|
+
return f"{col} > ?", [pred.value]
|
|
76
|
+
if op == "ge":
|
|
77
|
+
return f"{col} >= ?", [pred.value]
|
|
78
|
+
if op == "in":
|
|
79
|
+
if not isinstance(pred.value, (list, tuple)):
|
|
80
|
+
raise CapabilityInputError(
|
|
81
|
+
f"Op 'in' requires a list value (got {type(pred.value).__name__})",
|
|
82
|
+
fields_invalid=["value"],
|
|
83
|
+
)
|
|
84
|
+
return (f"{col} IN (SELECT value FROM json_each(?))",
|
|
85
|
+
[json.dumps(list(pred.value))])
|
|
86
|
+
if op == "contains":
|
|
87
|
+
if not isinstance(pred.value, str):
|
|
88
|
+
raise CapabilityInputError(
|
|
89
|
+
f"Op 'contains' requires a string value (got {type(pred.value).__name__})",
|
|
90
|
+
fields_invalid=["value"],
|
|
91
|
+
)
|
|
92
|
+
# Defined case-INSENSITIVE (P12). Both sides through SQLite's lower()
|
|
93
|
+
# (ASCII folding); wildcards escaped so the match is literal.
|
|
94
|
+
return (f"lower({col}) LIKE '%' || lower(?) || '%' ESCAPE '\\'",
|
|
95
|
+
[_escape_like(pred.value)])
|
|
96
|
+
if op == "is_null":
|
|
97
|
+
return f"{col} IS NULL", []
|
|
98
|
+
if op == "not_null":
|
|
99
|
+
return f"{col} IS NOT NULL", []
|
|
100
|
+
raise CapabilityInputError(
|
|
101
|
+
f"Predicate op {pred.op!r} not supported by the sqlite translation",
|
|
102
|
+
fields_invalid=["op"],
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _source_match_sql(
|
|
107
|
+
sp: SourcePredicate, # Provenance match (content-hash-primary per CR-19)
|
|
108
|
+
sources_expr: str, # SQL expression for the sources JSON column (e.g. "n.sources")
|
|
109
|
+
) -> Tuple[str, List[Any]]: # (EXISTS fragment, bound params)
|
|
110
|
+
"""Compile a source predicate to an EXISTS over the sources array.
|
|
111
|
+
|
|
112
|
+
Content-hash-primary (identity field = the stable query surface, C19).
|
|
113
|
+
A locator constraint RAISES — unsupported in the typed translation
|
|
114
|
+
(use `find_nodes_by_source` for locator equality; recurring need here
|
|
115
|
+
is the promotion evidence the raw-escape posture wants recorded).
|
|
116
|
+
"""
|
|
117
|
+
if sp.locator is not None:
|
|
118
|
+
raise CapabilityInputError(
|
|
119
|
+
"SourcePredicate.locator is not supported by the sqlite typed "
|
|
120
|
+
"translation (content-hash-primary); use find_nodes_by_source",
|
|
121
|
+
fields_invalid=["locator"],
|
|
122
|
+
)
|
|
123
|
+
return (f"EXISTS (SELECT 1 FROM json_each({sources_expr}) AS src "
|
|
124
|
+
f"WHERE json_extract(src.value, '$.content_hash') = ?)",
|
|
125
|
+
[sp.content_hash])
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _relation_exists_sql(
|
|
129
|
+
rel: RelationPredicate, # One-hop relation constraint (+ far-end constraints)
|
|
130
|
+
node_expr: str, # SQL expression for the candidate node id (e.g. "n.id", "e.source_id")
|
|
131
|
+
) -> Tuple[str, List[Any]]: # (EXISTS fragment, bound params)
|
|
132
|
+
"""Compile a relation predicate to a correlated EXISTS (no row multiplication).
|
|
133
|
+
|
|
134
|
+
Far-end constraints (stage-4 promotions): `node_id` / `node_ids` pin the
|
|
135
|
+
far node; `node_source` nests a provenance EXISTS on the far node.
|
|
136
|
+
Subquery scoping keeps the fixed aliases (r / fn / src) collision-free.
|
|
137
|
+
"""
|
|
138
|
+
params: List[Any] = [rel.relation_type]
|
|
139
|
+
if rel.direction == "out":
|
|
140
|
+
join_cond = f"r.source_id = {node_expr}"
|
|
141
|
+
far = "r.target_id"
|
|
142
|
+
elif rel.direction == "in":
|
|
143
|
+
join_cond = f"r.target_id = {node_expr}"
|
|
144
|
+
far = "r.source_id"
|
|
145
|
+
else: # both
|
|
146
|
+
join_cond = f"(r.source_id = {node_expr} OR r.target_id = {node_expr})"
|
|
147
|
+
far = (f"(CASE WHEN r.source_id = {node_expr} "
|
|
148
|
+
f"THEN r.target_id ELSE r.source_id END)")
|
|
149
|
+
conds = [join_cond, "r.relation_type = ?"]
|
|
150
|
+
if rel.node_id is not None:
|
|
151
|
+
conds.append(f"{far} = ?")
|
|
152
|
+
params.append(rel.node_id)
|
|
153
|
+
if rel.node_ids is not None:
|
|
154
|
+
conds.append(f"{far} IN (SELECT value FROM json_each(?))")
|
|
155
|
+
params.append(json.dumps(list(rel.node_ids)))
|
|
156
|
+
if rel.node_source is not None:
|
|
157
|
+
src_frag, src_params = _source_match_sql(rel.node_source, "fn.sources")
|
|
158
|
+
conds.append(
|
|
159
|
+
f"EXISTS (SELECT 1 FROM nodes AS fn WHERE fn.id = {far} AND {src_frag})")
|
|
160
|
+
params.extend(src_params)
|
|
161
|
+
return f"EXISTS (SELECT 1 FROM edges AS r WHERE {' AND '.join(conds)})", params
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
NODE_FULL_COLUMNS = "n.id, n.label, n.properties, n.sources, n.created_at, n.updated_at" # Matches _row_to_node order
|
|
165
|
+
EDGE_FULL_COLUMNS = "e.id, e.source_id, e.target_id, e.relation_type, e.properties, e.created_at, e.updated_at" # Matches _row_to_edge order
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _order_limit_sql(
|
|
169
|
+
query, # NodeQuery or EdgeQuery (order_by / limit / offset fields)
|
|
170
|
+
props_col: str, # Properties column expression for ORDER BY paths
|
|
171
|
+
params: List[Any], # Bound-params list (appended in place)
|
|
172
|
+
) -> str: # ORDER BY / LIMIT / OFFSET tail
|
|
173
|
+
"""Compile the shared ordering + paging tail."""
|
|
174
|
+
tail = ""
|
|
175
|
+
if query.order_by is not None:
|
|
176
|
+
tail += (f" ORDER BY json_extract({props_col}, "
|
|
177
|
+
f"{_json_path(query.order_by.prop)})"
|
|
178
|
+
+ (" DESC" if query.order_by.descending else " ASC"))
|
|
179
|
+
if query.limit is not None or query.offset:
|
|
180
|
+
tail += " LIMIT ?"
|
|
181
|
+
params.append(query.limit if query.limit is not None else -1)
|
|
182
|
+
if query.offset:
|
|
183
|
+
tail += " OFFSET ?"
|
|
184
|
+
params.append(query.offset)
|
|
185
|
+
return tail
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def translate_node_query(
|
|
189
|
+
q: NodeQuery, # Typed node query
|
|
190
|
+
) -> Tuple[str, List[Any], str, Optional[List[str]]]: # (sql, params, mode, row keys)
|
|
191
|
+
"""Translate a `NodeQuery` to parameterized SQLite SQL.
|
|
192
|
+
|
|
193
|
+
mode: "count" | "rows" | "full" (count > project > full, mirroring the
|
|
194
|
+
result DTO's exactly-one-populated contract). For "rows", the returned
|
|
195
|
+
keys list zips against each cursor row ("id" always first; "label"
|
|
196
|
+
projects structurally; "sources" projects as the raw JSON column for the
|
|
197
|
+
caller to parse).
|
|
198
|
+
"""
|
|
199
|
+
where: List[str] = []
|
|
200
|
+
params: List[Any] = []
|
|
201
|
+
if q.ids is not None:
|
|
202
|
+
where.append("n.id IN (SELECT value FROM json_each(?))")
|
|
203
|
+
params.append(json.dumps(list(q.ids)))
|
|
204
|
+
if q.label is not None:
|
|
205
|
+
where.append("n.label = ?")
|
|
206
|
+
params.append(q.label)
|
|
207
|
+
for pred in q.where:
|
|
208
|
+
frag, ps = _predicate_sql(pred, "n.properties")
|
|
209
|
+
where.append(frag)
|
|
210
|
+
params.extend(ps)
|
|
211
|
+
if q.source is not None:
|
|
212
|
+
frag, ps = _source_match_sql(q.source, "n.sources")
|
|
213
|
+
where.append(frag)
|
|
214
|
+
params.extend(ps)
|
|
215
|
+
if q.related is not None:
|
|
216
|
+
frag, ps = _relation_exists_sql(q.related, "n.id")
|
|
217
|
+
where.append(frag)
|
|
218
|
+
params.extend(ps)
|
|
219
|
+
where_sql = (" WHERE " + " AND ".join(where)) if where else ""
|
|
220
|
+
|
|
221
|
+
if q.count:
|
|
222
|
+
return (f"SELECT COUNT(*) FROM nodes AS n{where_sql}", params, "count", None)
|
|
223
|
+
|
|
224
|
+
if q.project is not None:
|
|
225
|
+
keys = ["id"]
|
|
226
|
+
select_parts = ["n.id"]
|
|
227
|
+
for name in q.project:
|
|
228
|
+
if name == "id":
|
|
229
|
+
continue
|
|
230
|
+
if name == "label":
|
|
231
|
+
select_parts.append("n.label")
|
|
232
|
+
keys.append("label")
|
|
233
|
+
elif name == "sources":
|
|
234
|
+
select_parts.append("n.sources")
|
|
235
|
+
keys.append("sources")
|
|
236
|
+
else:
|
|
237
|
+
select_parts.append(f"json_extract(n.properties, {_json_path(name)})")
|
|
238
|
+
keys.append(name)
|
|
239
|
+
tail = _order_limit_sql(q, "n.properties", params)
|
|
240
|
+
return (f"SELECT {', '.join(select_parts)} FROM nodes AS n{where_sql}{tail}",
|
|
241
|
+
params, "rows", keys)
|
|
242
|
+
|
|
243
|
+
tail = _order_limit_sql(q, "n.properties", params)
|
|
244
|
+
return (f"SELECT {NODE_FULL_COLUMNS} FROM nodes AS n{where_sql}{tail}",
|
|
245
|
+
params, "full", None)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def translate_edge_query(
|
|
249
|
+
q: EdgeQuery, # Typed edge query
|
|
250
|
+
) -> Tuple[str, List[Any], str, Optional[List[str]]]: # (sql, params, mode, row keys)
|
|
251
|
+
"""Translate an `EdgeQuery` to parameterized SQLite SQL.
|
|
252
|
+
|
|
253
|
+
Same mode contract as `translate_node_query`. Projected rows always carry
|
|
254
|
+
`id`/`source_id`/`target_id`; `relation_type` projects structurally.
|
|
255
|
+
Endpoint constraints (`source_related`/`target_related` — the D13
|
|
256
|
+
NEXT-chain count) compile to correlated EXISTS on the endpoint node.
|
|
257
|
+
"""
|
|
258
|
+
where: List[str] = []
|
|
259
|
+
params: List[Any] = []
|
|
260
|
+
if q.ids is not None:
|
|
261
|
+
where.append("e.id IN (SELECT value FROM json_each(?))")
|
|
262
|
+
params.append(json.dumps(list(q.ids)))
|
|
263
|
+
if q.relation_type is not None:
|
|
264
|
+
where.append("e.relation_type = ?")
|
|
265
|
+
params.append(q.relation_type)
|
|
266
|
+
if q.source_id is not None:
|
|
267
|
+
where.append("e.source_id = ?")
|
|
268
|
+
params.append(q.source_id)
|
|
269
|
+
if q.target_id is not None:
|
|
270
|
+
where.append("e.target_id = ?")
|
|
271
|
+
params.append(q.target_id)
|
|
272
|
+
if q.source_ids is not None:
|
|
273
|
+
where.append("e.source_id IN (SELECT value FROM json_each(?))")
|
|
274
|
+
params.append(json.dumps(list(q.source_ids)))
|
|
275
|
+
if q.target_ids is not None:
|
|
276
|
+
where.append("e.target_id IN (SELECT value FROM json_each(?))")
|
|
277
|
+
params.append(json.dumps(list(q.target_ids)))
|
|
278
|
+
if q.source_related is not None:
|
|
279
|
+
frag, ps = _relation_exists_sql(q.source_related, "e.source_id")
|
|
280
|
+
where.append(frag)
|
|
281
|
+
params.extend(ps)
|
|
282
|
+
if q.target_related is not None:
|
|
283
|
+
frag, ps = _relation_exists_sql(q.target_related, "e.target_id")
|
|
284
|
+
where.append(frag)
|
|
285
|
+
params.extend(ps)
|
|
286
|
+
for pred in q.where:
|
|
287
|
+
frag, ps = _predicate_sql(pred, "e.properties")
|
|
288
|
+
where.append(frag)
|
|
289
|
+
params.extend(ps)
|
|
290
|
+
where_sql = (" WHERE " + " AND ".join(where)) if where else ""
|
|
291
|
+
|
|
292
|
+
if q.count:
|
|
293
|
+
return (f"SELECT COUNT(*) FROM edges AS e{where_sql}", params, "count", None)
|
|
294
|
+
|
|
295
|
+
if q.project is not None:
|
|
296
|
+
keys = ["id", "source_id", "target_id"]
|
|
297
|
+
select_parts = ["e.id", "e.source_id", "e.target_id"]
|
|
298
|
+
for name in q.project:
|
|
299
|
+
if name in ("id", "source_id", "target_id"):
|
|
300
|
+
continue
|
|
301
|
+
if name == "relation_type":
|
|
302
|
+
select_parts.append("e.relation_type")
|
|
303
|
+
keys.append("relation_type")
|
|
304
|
+
else:
|
|
305
|
+
select_parts.append(f"json_extract(e.properties, {_json_path(name)})")
|
|
306
|
+
keys.append(name)
|
|
307
|
+
tail = _order_limit_sql(q, "e.properties", params)
|
|
308
|
+
return (f"SELECT {', '.join(select_parts)} FROM edges AS e{where_sql}{tail}",
|
|
309
|
+
params, "rows", keys)
|
|
310
|
+
|
|
311
|
+
tail = _order_limit_sql(q, "e.properties", params)
|
|
312
|
+
return (f"SELECT {EDGE_FULL_COLUMNS} FROM edges AS e{where_sql}{tail}",
|
|
313
|
+
params, "full", None)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cjm-capability-graph-sqlite
|
|
3
|
+
Version: 0.0.26
|
|
4
|
+
Summary: A local, file-backed context-graph storage capability for the cjm-substrate runtime that implements graph storage, traversal, and querying using SQLite.
|
|
5
|
+
Author-email: "Christian J. Mills" <9126128+cj-mills@users.noreply.github.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/cj-mills/cjm-capability-graph-sqlite
|
|
8
|
+
Keywords: python
|
|
9
|
+
Classifier: Natural Language :: English
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: cjm-substrate>=0.0.51
|
|
18
|
+
Requires-Dist: cjm-context-graph-primitives>=0.0.12
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# cjm-capability-graph-sqlite
|
|
22
|
+
|
|
23
|
+
<!-- generated from the context graph by `cjm-context-graph readme` — do not edit by hand; edit the graph (the urge to hand-edit = move it on-graph) -->
|
|
24
|
+
|
|
25
|
+
A local, file-backed context-graph storage capability for the cjm-substrate runtime that implements graph storage, traversal, and querying using SQLite.
|
|
26
|
+
|
|
27
|
+
## Modules
|
|
28
|
+
|
|
29
|
+
- **`cjm_capability_graph_sqlite.capability`** — Capability implementation for Context Graph using SQLite.
|
|
30
|
+
- **`cjm_capability_graph_sqlite.query_translation`** — The per-backend translation of the typed query expressions (pass-2 Thread 5; stage 4): NodeQuery/EdgeQuery -> parameterized SQLite SQL over the nodes/edges schema. THIS module is what makes the typed surface portable - the expression is domain- and backend-neutral; every backend tool owns a translation like this one (the ratified stage-4 split: backend owns translation; the adapter stays generic). Pure functions, unit-tested against an in-memory DB with the production schema - no capability runtime needed.
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
### `cjm_capability_graph_sqlite.capability`
|
|
35
|
+
|
|
36
|
+
- `SQLiteGraphCapability` _class_ — Local, file-backed Context Graph implementation using SQLite.
|
|
37
|
+
- `SQLiteGraphCapabilityConfig` _class_ — Configuration for SQLite Graph Capability.
|
|
38
|
+
- `integrity_check` _function_ — Backend self-check (stage 4; the G3 corruption find institutionalized):
|
|
39
|
+
- `query_edges` _function_ — Execute a typed edge query (stage 4) — same contract as `query_nodes`.
|
|
40
|
+
- `query_nodes` _function_ — Execute a typed node query (stage 4) — translated to parameterized SQL
|
|
41
|
+
- `raw_query` _function_ — Execute the raw escape — refuses backend mismatches (non-portable by
|
|
42
|
+
|
|
43
|
+
### `cjm_capability_graph_sqlite.query_translation`
|
|
44
|
+
|
|
45
|
+
- `translate_edge_query` _function_ — Translate an `EdgeQuery` to parameterized SQLite SQL.
|
|
46
|
+
- `translate_node_query` _function_ — Translate a `NodeQuery` to parameterized SQLite SQL.
|
|
47
|
+
|
|
48
|
+
## Dependencies
|
|
49
|
+
|
|
50
|
+
**Depends on:** `cjm-context-graph-primitives`, `cjm-substrate`
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
cjm_capability_graph_sqlite/__init__.py,sha256=Uo7fyxQsD_ez-4T9Di7e8J56WgMQ2DYHGASt3lnRdUY,23
|
|
2
|
+
cjm_capability_graph_sqlite/capability.py,sha256=ngJhjqIgKb_1f1IS3EpaFLlFCFksKP62Dm8g8a57INo,38024
|
|
3
|
+
cjm_capability_graph_sqlite/query_translation.py,sha256=w5jZrKtIrVNDduARWMIvNvxjzbl7gXzUzwN0UQ78Wgk,14218
|
|
4
|
+
cjm_capability_graph_sqlite-0.0.26.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
|
|
5
|
+
cjm_capability_graph_sqlite-0.0.26.dist-info/METADATA,sha256=hL7LPQE6pmSmRHwuWARrwR7ayLOawaViUxo5AgPU4gc,2873
|
|
6
|
+
cjm_capability_graph_sqlite-0.0.26.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
7
|
+
cjm_capability_graph_sqlite-0.0.26.dist-info/top_level.txt,sha256=zMuwCou7YR7_N4_jmBrVO8LIY4LgaF3KXma9MBSnEYY,28
|
|
8
|
+
cjm_capability_graph_sqlite-0.0.26.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2022, fastai
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cjm_capability_graph_sqlite
|