verifiably-nodes 0.2.0__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.
- verifiably_nodes-0.2.0/.gitignore +14 -0
- verifiably_nodes-0.2.0/LICENSE +21 -0
- verifiably_nodes-0.2.0/PKG-INFO +53 -0
- verifiably_nodes-0.2.0/README.md +34 -0
- verifiably_nodes-0.2.0/pyproject.toml +49 -0
- verifiably_nodes-0.2.0/scripts/gen_search_oracle.py +28 -0
- verifiably_nodes-0.2.0/scripts/gen_similarity_oracle.py +62 -0
- verifiably_nodes-0.2.0/scripts/gen_tokenizer_oracle.py +33 -0
- verifiably_nodes-0.2.0/src/nodes/core/__init__.py +1 -0
- verifiably_nodes-0.2.0/src/nodes/core/corpus.py +521 -0
- verifiably_nodes-0.2.0/src/nodes/core/errors.py +66 -0
- verifiably_nodes-0.2.0/src/nodes/core/frontmatter.py +205 -0
- verifiably_nodes-0.2.0/src/nodes/core/ids.py +41 -0
- verifiably_nodes-0.2.0/src/nodes/core/node.py +45 -0
- verifiably_nodes-0.2.0/src/nodes/core/paths.py +99 -0
- verifiably_nodes-0.2.0/src/nodes/core/projection.py +79 -0
- verifiably_nodes-0.2.0/src/nodes/core/py.typed +0 -0
- verifiably_nodes-0.2.0/src/nodes/core/ranking.py +14 -0
- verifiably_nodes-0.2.0/src/nodes/core/registry.py +126 -0
- verifiably_nodes-0.2.0/src/nodes/core/relations.py +57 -0
- verifiably_nodes-0.2.0/src/nodes/core/search.py +251 -0
- verifiably_nodes-0.2.0/src/nodes/core/shapes.py +136 -0
- verifiably_nodes-0.2.0/src/nodes/core/similarity.py +322 -0
- verifiably_nodes-0.2.0/src/nodes/core/snapshot.py +186 -0
- verifiably_nodes-0.2.0/src/nodes/core/store.py +52 -0
- verifiably_nodes-0.2.0/src/nodes/core/structural_index.py +458 -0
- verifiably_nodes-0.2.0/src/nodes/core/write_plan.py +99 -0
- verifiably_nodes-0.2.0/tests/__init__.py +0 -0
- verifiably_nodes-0.2.0/tests/_executors.py +17 -0
- verifiably_nodes-0.2.0/tests/_fixtures_profile.py +60 -0
- verifiably_nodes-0.2.0/tests/test_check_parity.py +36 -0
- verifiably_nodes-0.2.0/tests/test_containment_parity.py +138 -0
- verifiably_nodes-0.2.0/tests/test_corpus.py +211 -0
- verifiably_nodes-0.2.0/tests/test_corpus_check.py +93 -0
- verifiably_nodes-0.2.0/tests/test_corpus_construction.py +66 -0
- verifiably_nodes-0.2.0/tests/test_corpus_executor.py +148 -0
- verifiably_nodes-0.2.0/tests/test_corpus_parity.py +21 -0
- verifiably_nodes-0.2.0/tests/test_corpus_persistence.py +264 -0
- verifiably_nodes-0.2.0/tests/test_corpus_persistence_rename.py +133 -0
- verifiably_nodes-0.2.0/tests/test_corpus_registry.py +83 -0
- verifiably_nodes-0.2.0/tests/test_corpus_search.py +43 -0
- verifiably_nodes-0.2.0/tests/test_corpus_similarity.py +113 -0
- verifiably_nodes-0.2.0/tests/test_corpus_traversal.py +75 -0
- verifiably_nodes-0.2.0/tests/test_damaged_parity.py +204 -0
- verifiably_nodes-0.2.0/tests/test_errors.py +35 -0
- verifiably_nodes-0.2.0/tests/test_format_golden.py +23 -0
- verifiably_nodes-0.2.0/tests/test_frontmatter.py +139 -0
- verifiably_nodes-0.2.0/tests/test_ids.py +35 -0
- verifiably_nodes-0.2.0/tests/test_index.py +266 -0
- verifiably_nodes-0.2.0/tests/test_index_rebuild_equivalence.py +91 -0
- verifiably_nodes-0.2.0/tests/test_index_snapshot.py +368 -0
- verifiably_nodes-0.2.0/tests/test_namespace_layout.py +34 -0
- verifiably_nodes-0.2.0/tests/test_node.py +57 -0
- verifiably_nodes-0.2.0/tests/test_parity.py +90 -0
- verifiably_nodes-0.2.0/tests/test_path_collision_parity.py +155 -0
- verifiably_nodes-0.2.0/tests/test_paths.py +269 -0
- verifiably_nodes-0.2.0/tests/test_pypi_upload_check.py +103 -0
- verifiably_nodes-0.2.0/tests/test_ranking.py +15 -0
- verifiably_nodes-0.2.0/tests/test_registry.py +106 -0
- verifiably_nodes-0.2.0/tests/test_registry_check.py +86 -0
- verifiably_nodes-0.2.0/tests/test_relations.py +42 -0
- verifiably_nodes-0.2.0/tests/test_release_scripts.py +459 -0
- verifiably_nodes-0.2.0/tests/test_search_index.py +82 -0
- verifiably_nodes-0.2.0/tests/test_search_parity.py +33 -0
- verifiably_nodes-0.2.0/tests/test_search_query.py +86 -0
- verifiably_nodes-0.2.0/tests/test_search_snapshot.py +144 -0
- verifiably_nodes-0.2.0/tests/test_search_tokenizer.py +45 -0
- verifiably_nodes-0.2.0/tests/test_shapes.py +107 -0
- verifiably_nodes-0.2.0/tests/test_similarity_foundations.py +77 -0
- verifiably_nodes-0.2.0/tests/test_similarity_parity.py +69 -0
- verifiably_nodes-0.2.0/tests/test_snapshot_io.py +207 -0
- verifiably_nodes-0.2.0/tests/test_snapshot_load.py +466 -0
- verifiably_nodes-0.2.0/tests/test_store.py +145 -0
- verifiably_nodes-0.2.0/tests/test_traversal_parity.py +23 -0
- verifiably_nodes-0.2.0/tests/test_vector_cache.py +90 -0
- verifiably_nodes-0.2.0/tests/test_vector_index.py +115 -0
- verifiably_nodes-0.2.0/tests/test_vector_query.py +122 -0
- verifiably_nodes-0.2.0/tests/test_vector_snapshot.py +287 -0
- verifiably_nodes-0.2.0/tests/test_write_plan.py +267 -0
- verifiably_nodes-0.2.0/tests/test_write_plan_parity.py +50 -0
- verifiably_nodes-0.2.0/uv.lock +482 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
.pytest_cache/
|
|
4
|
+
.ruff_cache/
|
|
5
|
+
.venv/
|
|
6
|
+
node_modules/
|
|
7
|
+
ts/dist/
|
|
8
|
+
.nodes-index/
|
|
9
|
+
|
|
10
|
+
# Fallback test-timing log, written by tools/tt when the shared log is unwritable and
|
|
11
|
+
# emptied by ops `tt-report`; never committed.
|
|
12
|
+
.tt/
|
|
13
|
+
# pytest-testmon's per-checkout selection database, rebuilt on demand.
|
|
14
|
+
.testmondata*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Keith Hughitt
|
|
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,53 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: verifiably-nodes
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Import-Name: nodes.core
|
|
5
|
+
Import-Namespace: nodes
|
|
6
|
+
Summary: Nodes core: a problem-agnostic knowledge substrate
|
|
7
|
+
Project-URL: Homepage, https://github.com/verifiably/nodes
|
|
8
|
+
Project-URL: Repository, https://github.com/verifiably/nodes
|
|
9
|
+
Project-URL: Issues, https://github.com/verifiably/nodes/issues
|
|
10
|
+
Author-email: Keith Hughitt <keith.hughitt@gmail.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Requires-Dist: pydantic>=2.0
|
|
16
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
17
|
+
Requires-Dist: rfc8785<0.2,>=0.1.4
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# verifiably-nodes
|
|
21
|
+
|
|
22
|
+
Nodes core: a problem-agnostic knowledge substrate.
|
|
23
|
+
|
|
24
|
+
`verifiably-nodes` is the Python implementation of the Nodes kernel — a portable
|
|
25
|
+
corpus of plain-text nodes with typed relations, structural shapes, and
|
|
26
|
+
derived full-text-search and similarity indexes. A TypeScript implementation
|
|
27
|
+
([`@verifiably/nodes`](https://www.npmjs.com/package/@verifiably/nodes)) passes
|
|
28
|
+
the same cross-language conformance fixtures.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
pip install verifiably-nodes
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Use
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import nodes.core
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The `nodes` namespace is a PEP 420 native namespace package; `verifiably-nodes`
|
|
43
|
+
ships exactly the `nodes.core` subpackage.
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
The language-neutral format and behavior specification, both
|
|
48
|
+
implementations, and the shared conformance fixtures live at
|
|
49
|
+
<https://github.com/verifiably/nodes>.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# verifiably-nodes
|
|
2
|
+
|
|
3
|
+
Nodes core: a problem-agnostic knowledge substrate.
|
|
4
|
+
|
|
5
|
+
`verifiably-nodes` is the Python implementation of the Nodes kernel — a portable
|
|
6
|
+
corpus of plain-text nodes with typed relations, structural shapes, and
|
|
7
|
+
derived full-text-search and similarity indexes. A TypeScript implementation
|
|
8
|
+
([`@verifiably/nodes`](https://www.npmjs.com/package/@verifiably/nodes)) passes
|
|
9
|
+
the same cross-language conformance fixtures.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
pip install verifiably-nodes
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Use
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import nodes.core
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The `nodes` namespace is a PEP 420 native namespace package; `verifiably-nodes`
|
|
24
|
+
ships exactly the `nodes.core` subpackage.
|
|
25
|
+
|
|
26
|
+
## Documentation
|
|
27
|
+
|
|
28
|
+
The language-neutral format and behavior specification, both
|
|
29
|
+
implementations, and the shared conformance fixtures live at
|
|
30
|
+
<https://github.com/verifiably/nodes>.
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "verifiably-nodes"
|
|
3
|
+
import-names = ["nodes.core"]
|
|
4
|
+
import-namespaces = ["nodes"]
|
|
5
|
+
version = "0.2.0"
|
|
6
|
+
description = "Nodes core: a problem-agnostic knowledge substrate"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
license = "MIT"
|
|
9
|
+
license-files = ["LICENSE"]
|
|
10
|
+
authors = [{ name = "Keith Hughitt", email = "keith.hughitt@gmail.com" }]
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
classifiers = ["Typing :: Typed"]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"pydantic>=2.0",
|
|
15
|
+
"pyyaml>=6.0.3",
|
|
16
|
+
"rfc8785>=0.1.4,<0.2",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/verifiably/nodes"
|
|
21
|
+
Repository = "https://github.com/verifiably/nodes"
|
|
22
|
+
Issues = "https://github.com/verifiably/nodes/issues"
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["hatchling>=1.30"]
|
|
26
|
+
build-backend = "hatchling.build"
|
|
27
|
+
|
|
28
|
+
[tool.hatch.build.targets.wheel]
|
|
29
|
+
core-metadata-version = "2.5"
|
|
30
|
+
packages = ["src/nodes"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
addopts = "-q"
|
|
34
|
+
testpaths = ["tests"]
|
|
35
|
+
|
|
36
|
+
[tool.ruff]
|
|
37
|
+
line-length = 120
|
|
38
|
+
|
|
39
|
+
[tool.pyright]
|
|
40
|
+
pythonVersion = "3.11"
|
|
41
|
+
typeCheckingMode = "basic"
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest>=9.0",
|
|
46
|
+
"ruff>=0.15.7",
|
|
47
|
+
"pyright>=1.1.390",
|
|
48
|
+
"pytest-testmon>=2.2.0",
|
|
49
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from nodes.core.corpus import Corpus
|
|
7
|
+
from nodes.core.ranking import score_key
|
|
8
|
+
|
|
9
|
+
FIXTURES = Path(__file__).parent.parent.parent / "fixtures"
|
|
10
|
+
CORPUS = FIXTURES / "search-corpus"
|
|
11
|
+
ORACLE = FIXTURES / "search.oracle.json"
|
|
12
|
+
|
|
13
|
+
QUERIES = ["search", "documents ranking", "relevance"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main() -> None:
|
|
17
|
+
corpus = Corpus(CORPUS)
|
|
18
|
+
cases = []
|
|
19
|
+
for query in QUERIES:
|
|
20
|
+
hits = corpus.search(query)
|
|
21
|
+
cases.append(
|
|
22
|
+
{"query": query, "hits": [{"id": h.id, "score": score_key(h.score)} for h in hits]}
|
|
23
|
+
)
|
|
24
|
+
ORACLE.write_text(json.dumps(cases, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
main()
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import shutil
|
|
5
|
+
import tempfile
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from nodes.core.corpus import Corpus
|
|
9
|
+
from nodes.core.ranking import score_key
|
|
10
|
+
from nodes.core.similarity import Vector, embed_text
|
|
11
|
+
|
|
12
|
+
FIXTURES = Path(__file__).parent.parent.parent / "fixtures"
|
|
13
|
+
CORPUS = FIXTURES / "similarity-corpus"
|
|
14
|
+
VECTORS = FIXTURES / "similarity.vectors.json"
|
|
15
|
+
ORACLE = FIXTURES / "similarity.oracle.json"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class LookupEmbedder:
|
|
19
|
+
cache_namespace = "fixture-v1"
|
|
20
|
+
|
|
21
|
+
def __init__(self, table: dict[str, Vector]) -> None:
|
|
22
|
+
self._table = table
|
|
23
|
+
|
|
24
|
+
def embed(self, texts: list[str]) -> list[Vector]:
|
|
25
|
+
return [self._table[t] for t in texts]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def build_table(data: dict, nodes: list) -> dict[str, Vector]:
|
|
29
|
+
by_id = {d["id"]: tuple(d["vector"]) for d in data["documents"]}
|
|
30
|
+
table: dict[str, Vector] = {embed_text(n): by_id[n.id] for n in nodes}
|
|
31
|
+
for q in data["queries"]:
|
|
32
|
+
table[q["text"]] = tuple(q["vector"])
|
|
33
|
+
return table
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _hits(hits) -> list[dict]:
|
|
37
|
+
return [{"id": h.id, "score": score_key(h.score)} for h in hits]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def main() -> None:
|
|
41
|
+
data = json.loads(VECTORS.read_text(encoding="utf-8"))
|
|
42
|
+
with tempfile.TemporaryDirectory() as td:
|
|
43
|
+
dst = Path(td) / "similarity-corpus"
|
|
44
|
+
shutil.copytree(CORPUS, dst)
|
|
45
|
+
nodes = Corpus(dst).all() # plain read, no embedder
|
|
46
|
+
emb = LookupEmbedder(build_table(data, nodes))
|
|
47
|
+
corpus = Corpus(dst, embedder=emb)
|
|
48
|
+
cases = {
|
|
49
|
+
"similar": [{"ref": d["id"], "hits": _hits(corpus.similar(d["id"]))} for d in data["documents"]],
|
|
50
|
+
"query_vector": [
|
|
51
|
+
{"text": q["text"], "hits": _hits(corpus.query_vector(tuple(q["vector"])))}
|
|
52
|
+
for q in data["queries"]
|
|
53
|
+
],
|
|
54
|
+
"similar_text": [
|
|
55
|
+
{"text": q["text"], "hits": _hits(corpus.similar_text(q["text"]))} for q in data["queries"]
|
|
56
|
+
],
|
|
57
|
+
}
|
|
58
|
+
ORACLE.write_text(json.dumps(cases, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
main()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from nodes.core.search import tokenize
|
|
7
|
+
|
|
8
|
+
ORACLE = Path(__file__).parent.parent.parent / "fixtures" / "search.tokenizer.json"
|
|
9
|
+
|
|
10
|
+
INPUTS = [
|
|
11
|
+
"",
|
|
12
|
+
" \t\n ",
|
|
13
|
+
"The Quick Brown Fox",
|
|
14
|
+
"the THE The",
|
|
15
|
+
"well-known",
|
|
16
|
+
"state_of_art",
|
|
17
|
+
"don't",
|
|
18
|
+
"3.14 and 2",
|
|
19
|
+
"café", # composed U+00E9
|
|
20
|
+
"café", # decomposed e + combining acute
|
|
21
|
+
"Hello МИР", # Cyrillic
|
|
22
|
+
"hello 世界", # CJK
|
|
23
|
+
"data\U0001D7D9point", # non-BMP MATHEMATICAL DOUBLE-STRUCK DIGIT ONE inside a token
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def main() -> None:
|
|
28
|
+
cases = [{"input": text, "tokens": tokenize(text)} for text in INPUTS]
|
|
29
|
+
ORACLE.write_text(json.dumps(cases, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from __future__ import annotations
|