minigdb 0.1.1__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.
Files changed (56) hide show
  1. minigdb-0.1.1/.github/workflows/release.yml +189 -0
  2. minigdb-0.1.1/.gitignore +43 -0
  3. minigdb-0.1.1/CONTRIBUTING.md +276 -0
  4. minigdb-0.1.1/Cargo.lock +2209 -0
  5. minigdb-0.1.1/Cargo.toml +60 -0
  6. minigdb-0.1.1/LICENSE +373 -0
  7. minigdb-0.1.1/PKG-INFO +185 -0
  8. minigdb-0.1.1/README.md +148 -0
  9. minigdb-0.1.1/demo/demo.py +174 -0
  10. minigdb-0.1.1/demo/example.ipynb +1372 -0
  11. minigdb-0.1.1/demo/random_graph_networkx.ipynb +807 -0
  12. minigdb-0.1.1/docs/algorithms.md +92 -0
  13. minigdb-0.1.1/docs/python.md +207 -0
  14. minigdb-0.1.1/docs/query-language.md +362 -0
  15. minigdb-0.1.1/docs/server.md +175 -0
  16. minigdb-0.1.1/pyproject.toml +46 -0
  17. minigdb-0.1.1/src/algorithms/bfs.rs +365 -0
  18. minigdb-0.1.1/src/algorithms/centrality.rs +787 -0
  19. minigdb-0.1.1/src/algorithms/community.rs +251 -0
  20. minigdb-0.1.1/src/algorithms/components.rs +485 -0
  21. minigdb-0.1.1/src/algorithms/flow.rs +324 -0
  22. minigdb-0.1.1/src/algorithms/louvain.rs +811 -0
  23. minigdb-0.1.1/src/algorithms/mod.rs +429 -0
  24. minigdb-0.1.1/src/algorithms/shortest_path.rs +374 -0
  25. minigdb-0.1.1/src/algorithms/similarity.rs +284 -0
  26. minigdb-0.1.1/src/algorithms/triangle.rs +299 -0
  27. minigdb-0.1.1/src/csv_import.rs +465 -0
  28. minigdb-0.1.1/src/gql.pest +328 -0
  29. minigdb-0.1.1/src/graph/constraints.rs +80 -0
  30. minigdb-0.1.1/src/graph/mod.rs +952 -0
  31. minigdb-0.1.1/src/graph/ops.rs +521 -0
  32. minigdb-0.1.1/src/lib.rs +49 -0
  33. minigdb-0.1.1/src/main.rs +984 -0
  34. minigdb-0.1.1/src/python.rs +1015 -0
  35. minigdb-0.1.1/src/query/ast.rs +606 -0
  36. minigdb-0.1.1/src/query/executor.rs +6859 -0
  37. minigdb-0.1.1/src/query/mod.rs +83 -0
  38. minigdb-0.1.1/src/query/parser.rs +1706 -0
  39. minigdb-0.1.1/src/server/auth.rs +94 -0
  40. minigdb-0.1.1/src/server/http.rs +642 -0
  41. minigdb-0.1.1/src/server/mod.rs +1422 -0
  42. minigdb-0.1.1/src/server/protocol.rs +149 -0
  43. minigdb-0.1.1/src/server/registry.rs +157 -0
  44. minigdb-0.1.1/src/server/static/assets/minigdb_logo.webp +0 -0
  45. minigdb-0.1.1/src/server/static/gui.html +1131 -0
  46. minigdb-0.1.1/src/storage/mod.rs +131 -0
  47. minigdb-0.1.1/src/storage/rocks_store.rs +1527 -0
  48. minigdb-0.1.1/src/transaction/mod.rs +53 -0
  49. minigdb-0.1.1/src/transaction/operation.rs +50 -0
  50. minigdb-0.1.1/src/types/edge.rs +43 -0
  51. minigdb-0.1.1/src/types/error.rs +60 -0
  52. minigdb-0.1.1/src/types/id.rs +108 -0
  53. minigdb-0.1.1/src/types/mod.rs +23 -0
  54. minigdb-0.1.1/src/types/node.rs +29 -0
  55. minigdb-0.1.1/src/types/value.rs +169 -0
  56. minigdb-0.1.1/tests/test_api.py +358 -0
@@ -0,0 +1,189 @@
1
+ name: Release
2
+
3
+ # Triggered by pushing a version tag: git tag v0.2.1 && git push --tags
4
+ on:
5
+ push:
6
+ tags:
7
+ - "v*"
8
+ workflow_dispatch:
9
+
10
+ env:
11
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
12
+
13
+ jobs:
14
+ # ── Build wheels for all supported platforms ─────────────────────────────
15
+ build-wheels:
16
+ name: Wheel — ${{ matrix.name }}
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ include:
21
+ # Linux x86_64 — quay.io/pypa/manylinux_2_28_x86_64 (AlmaLinux 8).
22
+ # librocksdb-sys needs libclang for bindgen; see before-script-linux below.
23
+ - name: linux-x86_64
24
+ os: ubuntu-latest
25
+ target: x86_64
26
+ manylinux: "2_28"
27
+ qemu: false
28
+ maturin-container: ""
29
+ python-version: ""
30
+
31
+ # Linux aarch64 — native ARM64 runner; no QEMU needed.
32
+ # maturin-action auto-selects quay.io/pypa/manylinux_2_28_aarch64 container.
33
+ - name: linux-aarch64
34
+ os: ubuntu-22.04-arm
35
+ target: aarch64
36
+ manylinux: "2_28"
37
+ qemu: false
38
+ maturin-container: ""
39
+ python-version: ""
40
+
41
+ # macOS universal2 — fat wheel for Intel + Apple Silicon.
42
+ # actions/setup-python pins Python 3.12 to avoid PyO3 0.22's ≤3.13 check;
43
+ # PYO3_USE_ABI3_FORWARD_COMPATIBILITY is a fallback for the cross-compile part.
44
+ - name: macos-universal
45
+ os: macos-latest
46
+ target: universal2-apple-darwin
47
+ manylinux: ""
48
+ qemu: false
49
+ maturin-container: ""
50
+ python-version: "3.12"
51
+
52
+ # Windows x86_64.
53
+ - name: windows-x86_64
54
+ os: windows-latest
55
+ target: x86_64
56
+ manylinux: ""
57
+ qemu: false
58
+ maturin-container: ""
59
+ python-version: ""
60
+
61
+ runs-on: ${{ matrix.os }}
62
+ steps:
63
+ - uses: actions/checkout@v4
64
+
65
+ # Required for linux-aarch64: registers QEMU binfmt handlers so Docker can
66
+ # run the native aarch64 manylinux container on an x86_64 host.
67
+ - uses: docker/setup-qemu-action@v3
68
+ if: matrix.qemu
69
+ with:
70
+ platforms: aarch64
71
+
72
+ # Pin Python on macOS to avoid PyO3 0.22's Python ≤ 3.13 version check.
73
+ - uses: actions/setup-python@v5
74
+ if: matrix.python-version != ''
75
+ with:
76
+ python-version: ${{ matrix.python-version }}
77
+
78
+ - name: Build wheel
79
+ uses: PyO3/maturin-action@v1
80
+ with:
81
+ target: ${{ matrix.target }}
82
+ args: --release --out dist --features python
83
+ manylinux: ${{ matrix.manylinux }}
84
+ container: ${{ matrix.maturin-container }}
85
+ # librocksdb-sys uses bindgen which requires libclang.
86
+ # On AlmaLinux 8 (manylinux_2_28), clang installs libclang.so into a
87
+ # versioned subdirectory (/usr/lib64/llvmN/lib/) that bindgen won't scan.
88
+ # We install clang+clang-devel then symlink the library into /usr/lib64/
89
+ # so bindgen finds it. before-script-linux is ignored on macOS/Windows.
90
+ before-script-linux: |
91
+ yum install -y clang clang-devel
92
+ LIBCLANG=$(find /usr/lib64 /usr/lib -name 'libclang.so*' -type f 2>/dev/null | sort | head -1)
93
+ if [ -n "$LIBCLANG" ]; then
94
+ ln -sf "$LIBCLANG" /usr/lib64/libclang.so
95
+ fi
96
+ env:
97
+ # Suppress PyO3 max-version check on Windows (no Docker, env is forwarded).
98
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
99
+ # RocksDB 8.10.0 uses C++17 aligned-allocation operators only available on
100
+ # macOS 10.13+. librocksdb-sys defaults to 10.12, which breaks the x86_64
101
+ # slice of the universal2 cross-compile. Ignored on Linux/Windows.
102
+ MACOSX_DEPLOYMENT_TARGET: "10.13"
103
+
104
+ - name: Upload wheel artifact
105
+ uses: actions/upload-artifact@v4
106
+ with:
107
+ name: wheels-${{ matrix.name }}
108
+ path: dist/*.whl
109
+
110
+ # ── Build source distribution (sdist) ────────────────────────────────────
111
+ # Users on unsupported platforms can install from source with:
112
+ # pip install minigdb --no-binary minigdb
113
+ # They need: Rust toolchain + cmake + C++ compiler.
114
+ build-sdist:
115
+ name: Source distribution
116
+ runs-on: ubuntu-latest
117
+ steps:
118
+ - uses: actions/checkout@v4
119
+
120
+ - name: Build sdist
121
+ uses: PyO3/maturin-action@v1
122
+ with:
123
+ command: sdist
124
+ args: --out dist
125
+
126
+ - name: Upload sdist artifact
127
+ uses: actions/upload-artifact@v4
128
+ with:
129
+ name: sdist
130
+ path: dist/*.tar.gz
131
+
132
+ # ── Publish to PyPI ───────────────────────────────────────────────────────
133
+ # Uses OIDC trusted publishing — no API token secret required.
134
+ publish:
135
+ name: Publish to PyPI
136
+ needs: [build-wheels, build-sdist]
137
+ if: startsWith(github.ref, 'refs/tags/v')
138
+ runs-on: ubuntu-latest
139
+ environment: pypi
140
+ permissions:
141
+ id-token: write # required for OIDC trusted publishing
142
+
143
+ steps:
144
+ - name: Download all wheel artifacts
145
+ uses: actions/download-artifact@v4
146
+ with:
147
+ pattern: "wheels-*"
148
+ merge-multiple: true
149
+ path: dist
150
+
151
+ - name: Download sdist artifact
152
+ uses: actions/download-artifact@v4
153
+ with:
154
+ name: sdist
155
+ path: dist
156
+
157
+ - name: Publish to PyPI
158
+ uses: pypa/gh-action-pypi-publish@release/v1
159
+ with:
160
+ skip-existing: true
161
+
162
+ # ── Create GitHub Release ─────────────────────────────────────────────────
163
+ github-release:
164
+ name: GitHub Release
165
+ needs: [publish]
166
+ if: startsWith(github.ref, 'refs/tags/v')
167
+ runs-on: ubuntu-latest
168
+ permissions:
169
+ contents: write # required to create releases
170
+
171
+ steps:
172
+ - name: Download all wheel artifacts
173
+ uses: actions/download-artifact@v4
174
+ with:
175
+ pattern: "wheels-*"
176
+ merge-multiple: true
177
+ path: dist
178
+
179
+ - name: Download sdist artifact
180
+ uses: actions/download-artifact@v4
181
+ with:
182
+ name: sdist
183
+ path: dist
184
+
185
+ - name: Create GitHub Release
186
+ uses: softprops/action-gh-release@v2
187
+ with:
188
+ files: dist/**
189
+ generate_release_notes: true
@@ -0,0 +1,43 @@
1
+ # Rust build output
2
+ /target
3
+
4
+ # macOS metadata
5
+ .DS_Store
6
+ **/.DS_Store
7
+
8
+ # minigdb runtime files (WAL, snapshots, REPL history)
9
+ /minigdb.wal
10
+ /minigdb.snap
11
+ /minigdb.snap.tmp
12
+ /.minigdb_history
13
+
14
+ # Named graph data directories created by the server / REPL
15
+ /graphs/
16
+
17
+ # RocksDB directories that may be created at the project root during testing
18
+ /minigdb_*/
19
+
20
+ # Python build artifacts (maturin / setuptools)
21
+ *.so
22
+ *.pyd
23
+ /dist/
24
+ /wheels/
25
+ /__pycache__/
26
+ **/__pycache__/
27
+ *.pyc
28
+ *.pyo
29
+ .venv/
30
+ venv/
31
+ *.egg-info/
32
+
33
+ # Jupyter notebook checkpoints
34
+ .ipynb_checkpoints/
35
+ **/.ipynb_checkpoints/
36
+
37
+ # Internal project files not for public repo
38
+ issues.md
39
+ completed.md
40
+ notes.md
41
+
42
+ # Claude Code session data
43
+ .claude/
@@ -0,0 +1,276 @@
1
+ # Contributing to minigdb
2
+
3
+ ---
4
+
5
+ ## Prerequisites
6
+
7
+ | Tool | Version | Install |
8
+ |------|---------|---------|
9
+ | Rust | stable (≥ 1.75) | [rustup.rs](https://rustup.rs) |
10
+ | cmake | ≥ 3.14 | `brew install cmake` / `apt install cmake` / [cmake.org](https://cmake.org) |
11
+ | C++ compiler | any modern | Xcode CLT / `build-essential` / MSVC |
12
+ | Python | ≥ 3.8 | [python.org](https://python.org) |
13
+ | maturin | ≥ 1.7 | `pip install maturin` |
14
+
15
+ cmake and a C++ compiler are required because RocksDB is compiled from source and linked statically into the library. This happens automatically on `cargo build` / `maturin develop` — you don't invoke cmake manually.
16
+
17
+ ---
18
+
19
+ ## Building
20
+
21
+ ### Rust binary / REPL
22
+
23
+ ```bash
24
+ cargo build # debug build
25
+ cargo build --release # optimised build
26
+
27
+ cargo run # launch the REPL (debug)
28
+ cargo run --release # launch the REPL (optimised)
29
+ ```
30
+
31
+ ### Run tests
32
+
33
+ ```bash
34
+ cargo test # all 331 tests
35
+ cargo test <filter> # e.g. cargo test transaction
36
+ cargo test -- --nocapture # show println! output
37
+ ```
38
+
39
+ Tests are hermetic — each test opens a `tempfile::TempDir`-backed RocksDB and cleans up on drop. No shared state between tests.
40
+
41
+ ### Python bindings (development)
42
+
43
+ ```bash
44
+ # Build and install into the active virtual environment
45
+ pip install maturin
46
+ maturin develop --features python
47
+
48
+ # Verify
49
+ python -c "import minigdb; print('ok')"
50
+ ```
51
+
52
+ `maturin develop` compiles a debug build and installs it as `minigdb` in the active venv. After any Rust source change, re-run `maturin develop` to pick it up.
53
+
54
+ For a release-optimised local build:
55
+
56
+ ```bash
57
+ maturin develop --release --features python
58
+ ```
59
+
60
+ ### Build a wheel locally (without publishing)
61
+
62
+ ```bash
63
+ maturin build --release --features python --out dist/
64
+ # → dist/minigdb-0.x.y-cp311-cp311-<platform>.whl
65
+
66
+ pip install dist/minigdb-*.whl
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Project structure
72
+
73
+ ```
74
+ src/
75
+ ├── main.rs # REPL, server entry points, graph management commands
76
+ ├── lib.rs # Public API re-exports
77
+ ├── gql.pest # PEG grammar (pest reads this at compile time from src/)
78
+ ├── python.rs # Python bindings (feature = "python")
79
+ ├── types/ # Value, NodeId/EdgeId (ULID), Node, Edge, DbError
80
+ ├── graph/ # Graph struct, RocksDB-backed ops (ops.rs)
81
+ ├── storage/ # RocksStore (8 column families), StorageManager
82
+ ├── transaction/ # Operation enum (replay units)
83
+ ├── algorithms/ # 15 graph algorithm modules dispatched via CALL
84
+ ├── query/ # AST (ast.rs), pest parser (parser.rs), executor (executor.rs)
85
+ └── server/
86
+ ├── mod.rs # Tokio TCP server, per-connection state, auth handshake
87
+ ├── auth.rs # ServerConfig, UserEntry, SHA-256 password hashing
88
+ ├── registry.rs # GraphRegistry — lazy-open, Arc<Mutex> per graph
89
+ ├── protocol.rs # Wire types: Request, Response, ClientMessage, ServerMessage
90
+ └── http.rs # Axum HTTP server + embedded GUI HTML (feature = "gui")
91
+ ```
92
+
93
+ ### Cargo features
94
+
95
+ | Feature | Default | What it enables |
96
+ |---------|---------|-----------------|
97
+ | `repl` | yes | Interactive REPL (rustyline + readline history) |
98
+ | `server` | yes | TCP server (tokio + SHA-256 auth) |
99
+ | `gui` | yes | Embedded HTTP GUI (axum); requires `server` |
100
+ | `python` | no | PyO3 Python bindings; build with `maturin develop --features python` |
101
+
102
+ To build only the core library without REPL or server:
103
+
104
+ ```bash
105
+ cargo build --no-default-features
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Making changes
111
+
112
+ ### Grammar changes
113
+
114
+ The PEG grammar lives in `src/gql.pest`. pest reads it at compile time using a
115
+ path relative to `src/`, so the file must stay at that location.
116
+
117
+ After editing the grammar, rebuild and run the parser tests:
118
+
119
+ ```bash
120
+ cargo test parser
121
+ ```
122
+
123
+ ### Adding a graph algorithm
124
+
125
+ 1. Add `src/algorithms/<name>.rs` implementing the algorithm against `GraphSnapshot`
126
+ 2. Register it in `src/algorithms/mod.rs` inside `dispatch_call()`
127
+ 3. Add at least one integration test in `tests/`
128
+
129
+ ### Modifying the Python API
130
+
131
+ Python bindings are in `src/python.rs`. After any change, run:
132
+
133
+ ```bash
134
+ maturin develop --features python
135
+ python -c "import minigdb; <smoke test>"
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Releasing a new version
141
+
142
+ ### 1. Update version numbers
143
+
144
+ Both files must be kept in sync — maturin uses `pyproject.toml` for the Python
145
+ package version and `Cargo.toml` for the crate version.
146
+
147
+ ```
148
+ pyproject.toml → [project] version = "0.x.y"
149
+ Cargo.toml → [package] version = "0.x.y"
150
+ ```
151
+
152
+ ### 2. Run the full test suite
153
+
154
+ ```bash
155
+ cargo test
156
+ ```
157
+
158
+ All tests must pass before tagging.
159
+
160
+ ### 3. Tag and push
161
+
162
+ ```bash
163
+ git tag v0.x.y
164
+ git push origin v0.x.y
165
+ ```
166
+
167
+ Pushing a `v*` tag triggers the release CI workflow (`.github/workflows/release.yml`).
168
+
169
+ ### 4. What CI does automatically
170
+
171
+ The workflow runs in parallel across four targets:
172
+
173
+ | Target | Runner | Notes |
174
+ |--------|--------|-------|
175
+ | Linux x86_64 | ubuntu-latest | Built inside manylinux_2_28 container |
176
+ | Linux aarch64 | ubuntu-latest | Cross-compiled via QEMU |
177
+ | macOS universal2 | macos-latest | Single fat wheel: Intel + Apple Silicon |
178
+ | Windows x86_64 | windows-latest | MSVC toolchain |
179
+
180
+ For each target, the workflow:
181
+ 1. Compiles RocksDB from source (C++, statically linked)
182
+ 2. Compiles the Rust library with `--features python`
183
+ 3. Packages the result as a `.whl` with maturin
184
+
185
+ After all wheels build successfully, CI also builds a source distribution (`sdist`) and uploads everything to PyPI via OIDC trusted publishing.
186
+
187
+ ### 5. Verify the release
188
+
189
+ ```bash
190
+ # In a fresh venv
191
+ pip install minigdb==0.x.y
192
+ python -c "import minigdb; db = minigdb.open('test'); db.query('INSERT (:T {x: 1})'); print(db.query('MATCH (n:T) RETURN n.x')); db.close()"
193
+ ```
194
+
195
+ ---
196
+
197
+ ## PyPI trusted publishing setup (one-time)
198
+
199
+ This only needs to be done once, before the first release.
200
+
201
+ **On PyPI:**
202
+ 1. Log in to [pypi.org](https://pypi.org) and go to Account Settings → Publishing
203
+ 2. Click **Add a new publisher**
204
+ 3. Fill in:
205
+ - PyPI project name: `minigdb`
206
+ - GitHub owner: `jerichomcleod`
207
+ - Repository name: `minigdb`
208
+ - Workflow filename: `release.yml`
209
+ - Environment name: `pypi`
210
+ 4. Save
211
+
212
+ **On GitHub:**
213
+ 1. Go to the repository Settings → Environments → **New environment**
214
+ 2. Name it `pypi`
215
+ 3. Optionally add a required reviewer as a manual approval gate before publish
216
+
217
+ **First publish:**
218
+
219
+ The first upload must be done manually to register the project name on PyPI (trusted
220
+ publishing only works for projects that already exist):
221
+
222
+ ```bash
223
+ maturin build --release --features python --out dist/
224
+ maturin upload dist/*
225
+ # prompts for PyPI username + password / API token
226
+ ```
227
+
228
+ After the first manual publish, all subsequent releases are fully automated by
229
+ pushing a version tag.
230
+
231
+ ---
232
+
233
+ ## Troubleshooting
234
+
235
+ ### RocksDB build fails locally
236
+
237
+ ```
238
+ error: failed to run custom build command for `rocksdb-sys`
239
+ ```
240
+
241
+ Make sure cmake and a C++ compiler are installed:
242
+
243
+ ```bash
244
+ # macOS
245
+ xcode-select --install
246
+ brew install cmake
247
+
248
+ # Ubuntu / Debian
249
+ sudo apt install cmake build-essential
250
+
251
+ # Windows
252
+ # Install Visual Studio Build Tools with "Desktop development with C++" workload
253
+ # Install cmake from https://cmake.org/download/
254
+ ```
255
+
256
+ ### `maturin develop` can't find Python
257
+
258
+ Activate your virtual environment first:
259
+
260
+ ```bash
261
+ python -m venv .venv
262
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
263
+ pip install maturin
264
+ maturin develop --features python
265
+ ```
266
+
267
+ ### Wheel installs but `import minigdb` fails on Linux
268
+
269
+ The pre-built wheels target `manylinux_2_28` (glibc 2.28+). If you are on an
270
+ older system (e.g. Ubuntu 18.04 with glibc 2.27), install from source:
271
+
272
+ ```bash
273
+ pip install minigdb --no-binary minigdb
274
+ ```
275
+
276
+ This requires Rust, cmake, and a C++ compiler on the host machine.