peql 0.3.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.
Files changed (102) hide show
  1. peql-0.3.0/.github/workflows/ci.yml +56 -0
  2. peql-0.3.0/.github/workflows/docs.yml +47 -0
  3. peql-0.3.0/.github/workflows/python-wheels.yml +79 -0
  4. peql-0.3.0/.gitignore +24 -0
  5. peql-0.3.0/CHANGELOG.md +91 -0
  6. peql-0.3.0/CONTRIBUTING.md +47 -0
  7. peql-0.3.0/Cargo.lock +8133 -0
  8. peql-0.3.0/Cargo.toml +172 -0
  9. peql-0.3.0/PKG-INFO +39 -0
  10. peql-0.3.0/README.md +91 -0
  11. peql-0.3.0/bindings/python/Cargo.lock +3352 -0
  12. peql-0.3.0/bindings/python/Cargo.toml +22 -0
  13. peql-0.3.0/bindings/python/README.md +27 -0
  14. peql-0.3.0/bindings/python/src/lib.rs +111 -0
  15. peql-0.3.0/bindings/python/tests/test_peql.py +133 -0
  16. peql-0.3.0/docs/ARCHITECTURE.md +100 -0
  17. peql-0.3.0/docs/CONTRACT-FORMAT.md +116 -0
  18. peql-0.3.0/docs/GRAPH-QUERY.md +80 -0
  19. peql-0.3.0/docs/USAGE.md +117 -0
  20. peql-0.3.0/docs/_static/peql-logo.jpeg +0 -0
  21. peql-0.3.0/docs/_static/peql.css +239 -0
  22. peql-0.3.0/docs/changelog.md +4 -0
  23. peql-0.3.0/docs/concepts.md +73 -0
  24. peql-0.3.0/docs/conf.py +26 -0
  25. peql-0.3.0/docs/contributing.md +19 -0
  26. peql-0.3.0/docs/getting-started.md +77 -0
  27. peql-0.3.0/docs/index.md +133 -0
  28. peql-0.3.0/docs/reference.md +47 -0
  29. peql-0.3.0/docs/requirements.txt +4 -0
  30. peql-0.3.0/examples/column_masking.rs +102 -0
  31. peql-0.3.0/examples/contract_query.rs +110 -0
  32. peql-0.3.0/examples/dp_noise.rs +113 -0
  33. peql-0.3.0/examples/graph_query.rs +119 -0
  34. peql-0.3.0/examples/plain_sql.rs +97 -0
  35. peql-0.3.0/examples/platform_bundle.rs +89 -0
  36. peql-0.3.0/examples/row_filter.rs +81 -0
  37. peql-0.3.0/fixtures/demo_dataset_users_v1.gdcpc.signed +224 -0
  38. peql-0.3.0/fixtures/graph/zijani-operations-v1/edges.parquet +0 -0
  39. peql-0.3.0/fixtures/graph/zijani-operations-v1/edges_rev.parquet +0 -0
  40. peql-0.3.0/fixtures/graph/zijani-operations-v1/manifest.json +1738 -0
  41. peql-0.3.0/fixtures/graph/zijani-operations-v1/nodes.parquet +0 -0
  42. peql-0.3.0/pyproject.toml +22 -0
  43. peql-0.3.0/python/peql/__init__.py +57 -0
  44. peql-0.3.0/rust-toolchain.toml +6 -0
  45. peql-0.3.0/src/app/documentation-technical/page.tsx +256 -0
  46. peql-0.3.0/src/binding.rs +107 -0
  47. peql-0.3.0/src/catalog.rs +145 -0
  48. peql-0.3.0/src/contract_source.rs +365 -0
  49. peql-0.3.0/src/contract_table_provider.rs +220 -0
  50. peql-0.3.0/src/engine.rs +260 -0
  51. peql-0.3.0/src/graph/bundle.rs +537 -0
  52. peql-0.3.0/src/graph/functions.rs +434 -0
  53. peql-0.3.0/src/graph/mod.rs +36 -0
  54. peql-0.3.0/src/graph/policy.rs +122 -0
  55. peql-0.3.0/src/graph/snapshot.rs +360 -0
  56. peql-0.3.0/src/graph/traverse.rs +550 -0
  57. peql-0.3.0/src/graph/types.rs +517 -0
  58. peql-0.3.0/src/lance_table.rs +460 -0
  59. peql-0.3.0/src/lib.rs +665 -0
  60. peql-0.3.0/src/long_running_pool_manager.rs +448 -0
  61. peql-0.3.0/src/optimizer_rules/contract_check.rs +498 -0
  62. peql-0.3.0/src/optimizer_rules/dp_noise.rs +534 -0
  63. peql-0.3.0/src/optimizer_rules/masking.rs +390 -0
  64. peql-0.3.0/src/optimizer_rules/mod.rs +152 -0
  65. peql-0.3.0/src/optimizer_rules/pipeline.rs +192 -0
  66. peql-0.3.0/src/optimizer_rules/row_filter.rs +421 -0
  67. peql-0.3.0/src/physical/attestation_exec.rs +402 -0
  68. peql-0.3.0/src/physical/contract_approved_exec.rs +180 -0
  69. peql-0.3.0/src/physical/laplace_noise_exec.rs +489 -0
  70. peql-0.3.0/src/physical/masking_exec.rs +716 -0
  71. peql-0.3.0/src/physical/mod.rs +207 -0
  72. peql-0.3.0/src/physical/row_filter_exec.rs +414 -0
  73. peql-0.3.0/src/physical/scan_metrics_exec.rs +241 -0
  74. peql-0.3.0/src/platform/bundle.rs +653 -0
  75. peql-0.3.0/src/platform/bundle_source.rs +95 -0
  76. peql-0.3.0/src/platform/mod.rs +32 -0
  77. peql-0.3.0/src/policy.rs +268 -0
  78. peql-0.3.0/src/query_cache.rs +275 -0
  79. peql-0.3.0/src/result_formatter.rs +384 -0
  80. peql-0.3.0/src/storaged_client.rs +346 -0
  81. peql-0.3.0/src/t05_client.rs +233 -0
  82. peql-0.3.0/tests/compile-fail/seal_violation.rs +27 -0
  83. peql-0.3.0/tests/compile-fail/seal_violation.stderr +25 -0
  84. peql-0.3.0/tests/contract_spine.rs +179 -0
  85. peql-0.3.0/tests/ddl_guard.rs +394 -0
  86. peql-0.3.0/tests/engine_shell.rs +480 -0
  87. peql-0.3.0/tests/graph_bundle.rs +282 -0
  88. peql-0.3.0/tests/graph_functions.rs +449 -0
  89. peql-0.3.0/tests/graph_traverse.rs +1107 -0
  90. peql-0.3.0/tests/integration/four_rule_pipeline.rs +215 -0
  91. peql-0.3.0/tests/integration/governed_numeric_mask.rs +236 -0
  92. peql-0.3.0/tests/platform_bundle.rs +57 -0
  93. peql-0.3.0/tests/seal_violation_trybuild.rs +28 -0
  94. peql-0.3.0/tests/unit/contract_check.rs +407 -0
  95. peql-0.3.0/tests/unit/dp_noise.rs +360 -0
  96. peql-0.3.0/tests/unit/masking.rs +377 -0
  97. peql-0.3.0/tests/unit/row_filter.rs +339 -0
  98. peql-0.3.0/tests/unit/wave9/attestation_exec.rs +705 -0
  99. peql-0.3.0/tests/unit/wave9/physical_contract_approved.rs +252 -0
  100. peql-0.3.0/tests/unit/wave9/physical_dp_noise.rs +605 -0
  101. peql-0.3.0/tests/unit/wave9/physical_masking.rs +872 -0
  102. peql-0.3.0/tests/unit/wave9/physical_row_filter.rs +401 -0
@@ -0,0 +1,56 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ env:
9
+ CARGO_TERM_COLOR: always
10
+ RUSTFLAGS: -D warnings
11
+
12
+ jobs:
13
+ build-and-test:
14
+ name: build · fmt · clippy · test
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Install Rust (stable)
20
+ uses: dtolnay/rust-toolchain@stable
21
+ with:
22
+ components: rustfmt, clippy
23
+
24
+ - name: Cache cargo
25
+ uses: Swatinem/rust-cache@v2
26
+
27
+ - name: rustfmt
28
+ run: cargo fmt --all --check
29
+
30
+ - name: clippy
31
+ run: cargo clippy --all-targets -- -D warnings
32
+
33
+ - name: test
34
+ run: cargo test
35
+
36
+ - name: build (release)
37
+ run: cargo build --release
38
+
39
+ # The platform adapter (T03 signed-bundle source) is feature-gated.
40
+ - name: clippy (platform)
41
+ run: cargo clippy --all-targets --features platform -- -D warnings
42
+
43
+ - name: test (platform)
44
+ run: cargo test --features platform
45
+
46
+ # Sanity-check that the examples actually run with no external services.
47
+ - name: run examples
48
+ run: |
49
+ for ex in plain_sql column_masking row_filter dp_noise contract_query graph_query; do
50
+ echo "::group::cargo run --example $ex"
51
+ cargo run --example "$ex"
52
+ echo "::endgroup::"
53
+ done
54
+ echo "::group::cargo run --example platform_bundle --features platform"
55
+ cargo run --example platform_bundle --features platform
56
+ echo "::endgroup::"
@@ -0,0 +1,47 @@
1
+ name: Documentation
2
+
3
+ on:
4
+ pull_request:
5
+ paths:
6
+ - "docs/**"
7
+ - ".github/workflows/docs.yml"
8
+ push:
9
+ branches: [main]
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ concurrency:
15
+ group: "pages-${{ github.event_name == 'pull_request' && github.ref || 'deploy' }}"
16
+ cancel-in-progress: false
17
+
18
+ jobs:
19
+ build:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.12"
26
+ - name: Install documentation dependencies
27
+ run: python -m pip install -r docs/requirements.txt
28
+ - name: Build site
29
+ run: sphinx-build -W --keep-going -b html docs docs/_build/html
30
+ - uses: actions/upload-pages-artifact@v3
31
+ with:
32
+ path: docs/_build/html
33
+
34
+ deploy:
35
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
36
+ needs: build
37
+ permissions:
38
+ pages: write
39
+ id-token: write
40
+ environment:
41
+ name: github-pages
42
+ url: ${{ steps.deployment.outputs.page_url }}
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - uses: actions/configure-pages@v5
46
+ - id: deployment
47
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,79 @@
1
+ name: python-wheels
2
+
3
+ # Build and publish pip-installable wheels. Release tags publish through PyPI
4
+ # Trusted Publishing; manual runs build and test artifacts only.
5
+ on:
6
+ push:
7
+ tags: ["v*"]
8
+ workflow_dispatch:
9
+
10
+ defaults:
11
+ run:
12
+ working-directory: bindings/python
13
+
14
+ jobs:
15
+ wheels:
16
+ name: wheels (${{ matrix.os }})
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ os: [ubuntu-latest, macos-latest, windows-latest]
21
+ runs-on: ${{ matrix.os }}
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: actions/setup-python@v5
25
+ with:
26
+ python-version: "3.12"
27
+
28
+ - name: Build wheels (abi3 — one wheel per platform covers Python ≥ 3.9)
29
+ uses: PyO3/maturin-action@v1
30
+ with:
31
+ working-directory: bindings/python
32
+ command: build
33
+ args: --release --out dist
34
+ manylinux: auto
35
+
36
+ - name: Smoke-test the wheel
37
+ shell: bash
38
+ run: |
39
+ python -m pip install --upgrade pip pyarrow pytest
40
+ python -m pip install --no-index --find-links dist peql
41
+ python -m pytest -q
42
+
43
+ - uses: actions/upload-artifact@v4
44
+ with:
45
+ name: wheels-${{ matrix.os }}
46
+ path: bindings/python/dist/*.whl
47
+
48
+ sdist:
49
+ name: sdist
50
+ runs-on: ubuntu-latest
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+ - uses: PyO3/maturin-action@v1
54
+ with:
55
+ working-directory: bindings/python
56
+ command: sdist
57
+ args: --out dist
58
+ - uses: actions/upload-artifact@v4
59
+ with:
60
+ name: sdist
61
+ path: bindings/python/dist/*.tar.gz
62
+
63
+ publish:
64
+ name: publish to PyPI
65
+ needs: [wheels, sdist]
66
+ if: startsWith(github.ref, 'refs/tags/v')
67
+ runs-on: ubuntu-latest
68
+ environment:
69
+ name: pypi
70
+ url: https://pypi.org/p/peql
71
+ permissions:
72
+ id-token: write
73
+ steps:
74
+ - uses: actions/download-artifact@v4
75
+ with:
76
+ path: dist
77
+ merge-multiple: true
78
+ - name: Publish tested distributions
79
+ uses: pypa/gh-action-pypi-publish@release/v1
peql-0.3.0/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ # Rust build artifacts
2
+ /target
3
+ **/target
4
+ **/*.rs.bk
5
+
6
+ # Python / maturin
7
+ .venv*/
8
+ **/__pycache__/
9
+ *.so
10
+ *.pyd
11
+ bindings/python/dist/
12
+ *.egg-info/
13
+ .pytest_cache/
14
+
15
+ # Backtrace / debug
16
+ *.pdb
17
+
18
+ # macOS
19
+ .DS_Store
20
+
21
+ # Editor / IDE
22
+ /.idea
23
+ /.vscode
24
+ *.swp
@@ -0,0 +1,91 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format is loosely
4
+ based on [Keep a Changelog](https://keepachangelog.com/).
5
+
6
+ ## [0.3.0] — graph queries, peQL naming, and documentation
7
+
8
+ This release follows `0.2.0`. The premature `v2.0.0` tag is withdrawn; the
9
+ graph work below is included in `0.3.0` instead. The Rust crate and Python
10
+ package are now named `peql`. The high-level Rust query type is `Engine`;
11
+ `K04DEngine` remains available as a separate lower-level Rust API. The
12
+ documentation is rebuilt with Sphinx and organized into learning, how-to,
13
+ reference, explanation, and contribution paths.
14
+
15
+ peQL traverses compiled business-process graphs in plain SQL, governed by
16
+ the same contract policy as tables.
17
+
18
+ - **Seven SQL table functions**: `graph_node`, `graph_neighbors`, `graph_edges`,
19
+ `graph_subtree`, `graph_path`, `graph_reachable`, and the relational
20
+ `graph_nodes` — each returns an ordinary table that composes with joins,
21
+ CTEs and aggregation. Positional arguments; results disclose
22
+ `snapshot_version` and (where capped) `truncated`.
23
+ - **Governed traversal**: a policy-filtered node is a **wall** — absent from
24
+ every result *and* non-traversable (no path routes through it; nothing
25
+ reachable only via it is reachable) — closing the topology-leak class. A
26
+ graph-only `edge_filter` hides relationships between visible nodes. Column
27
+ masks run through the real masking operators, byte-identical to tables.
28
+ Deny and unknown-graph are byte-identical (no existence oracle); unknown
29
+ nodes return near-miss suggestions.
30
+ - **Snapshot bundles** (G01 format): loaded from `nodes/edges/edges_rev.parquet`
31
+ + `manifest.json` with mandatory sha256 + `bundle_format` verification and
32
+ structural invariant checks; traversal runs on the precompiled CSR offset
33
+ columns — no query-time index build. Per-engine cache keyed by
34
+ (snapshot, policy fingerprint): bundles load once; different policies never
35
+ share a governed structure. v1 envelope ≤50k nodes / 200k edges, enforced.
36
+ - **Contract format**: graph datasets bind via `binding.graph_snapshot`;
37
+ policy via `masks`, `node_filter` (row_filter alias over node columns) and
38
+ `edge_filter`. `ResolvedPolicy` gains `graph_edge_filter`.
39
+ - **Python parity**: the same graph SQL works through the wheel unchanged;
40
+ list columns (`data_refs` …) round-trip to pyarrow.
41
+ - Verified end-to-end against the real compiled `zijani-operations` bundle
42
+ (271 nodes / 562 edges): examples/graph_query.rs + 10 SQL E2E tests,
43
+ 33 traversal-algorithm tests, and bundle loader tests.
44
+ - Design + as-built spec: [`docs/GRAPH-QUERY.md`](docs/GRAPH-QUERY.md).
45
+
46
+ ## [0.2.0] — contract resolution spine + platform adapter
47
+
48
+ Turned the engine from "mask a hand-fed batch" into "query a contract": you now
49
+ name a contract-bound dataset in SQL and get governed rows.
50
+
51
+ - **Contract resolution spine.** `SELECT … FROM "<dataset-uri>"` resolves the
52
+ governing contract for the caller and the physical data location, then applies
53
+ the contract's masking, row filtering and DP noise inside the query plan.
54
+ New modules: `policy` (`ResolvedPolicy` — the engine-agnostic enforcement
55
+ primitive), `contract_source` (`ContractSource` + `JsonContractSource`),
56
+ `binding` (`BindingResolver` + local Parquet loader), `contract_table_provider`
57
+ (`ContractTableProvider`), `catalog` (lazy DataFusion `SchemaProvider`/
58
+ `CatalogProvider`), and `engine` (`Engine`).
59
+ - **Open-source path.** A simple JSON contract format + local Parquet — no
60
+ services, no `protoc`. See `docs/CONTRACT-FORMAT.md`.
61
+ - **Platform adapter** (`--features platform`). `PlatformBundleSource` fetches a
62
+ Griot Cloud T03 signed bundle over HTTP, verifies its ECDSA-P256 signature
63
+ (canonical hashing mirrored from T03's `bundle-signer`), and maps it to the
64
+ same `ResolvedPolicy`. Exercised offline against the real committed bundle
65
+ fixture.
66
+ - New examples: `contract_query` (standalone) and `platform_bundle` (platform).
67
+ - Docs: `docs/USAGE.md`, `docs/CONTRACT-FORMAT.md`, `docs/ARCHITECTURE.md`.
68
+ - The pre-existing enforcement operators are reused unchanged.
69
+
70
+ ## [0.1.0] — initial snapshot
71
+
72
+ Initial standalone snapshot of the peQL query engine, **copied** out of the
73
+ Griot Cloud platform monorepo.
74
+
75
+ - **Source:** `griot-cloud` @ commit `5b999ed0010aeb86ae703076798f035b9c0c9121`
76
+ (path `zone-k/k04-workers/k04d-query-rs/`).
77
+ - Trimmed the cloud-only deployment glue (HTTP service wrapper, GCS/pgvector/
78
+ Redis clients, container/build manifests) and the legacy gRPC server so the
79
+ crate builds and runs standalone with only Rust + cargo.
80
+ - Pruned the now-unused dependencies; the default build needs no `protoc` and no
81
+ system libraries.
82
+ - Kept the engine intact: the DataFusion optimizer rules and physical operators
83
+ (contract check, row filter, column masking, differential-privacy noise,
84
+ attestation), the sealed engine core, and the DDL guard.
85
+ - Added four runnable examples (`plain_sql`, `column_masking`, `row_filter`,
86
+ `dp_noise`) that demonstrate governed output with zero external services.
87
+ - `lance` columnar support retained as an optional feature (off by default;
88
+ requires `protoc`).
89
+
90
+ The engine's behaviour is unchanged from the source commit; this release is a
91
+ packaging + documentation pass, not a redesign.
@@ -0,0 +1,47 @@
1
+ # Contributing to peQL
2
+
3
+ Thanks for your interest. peQL is a standalone snapshot of the query engine
4
+ from the Griot Cloud platform (see [Provenance](README.md#provenance)).
5
+
6
+ ## Development setup
7
+
8
+ You only need a recent stable Rust toolchain (≥ 1.88). Everything else is
9
+ vendored through cargo.
10
+
11
+ ```bash
12
+ git clone <this-repo> peql && cd peql
13
+ cargo build
14
+ cargo test
15
+ ```
16
+
17
+ ## Before you open a PR
18
+
19
+ Run the same gates CI runs (these must all pass):
20
+
21
+ ```bash
22
+ cargo fmt --all --check
23
+ cargo clippy --all-targets -- -D warnings
24
+ cargo test
25
+ cargo build --release
26
+ ```
27
+
28
+ - Keep the default feature set building **without `protoc`**. Anything that
29
+ needs `protoc` (e.g. the Lance columnar path) must stay behind the `lance`
30
+ feature.
31
+ - Match the surrounding style: the engine source predates clippy's inline
32
+ format-args lint, which is allowed crate-wide — don't churn unrelated lines.
33
+ - Add or update an example when you add user-visible behaviour, and make sure
34
+ `cargo run --example <name>` still works with no external services.
35
+
36
+ ## Scope
37
+
38
+ This repo packages the engine for standalone use. Deeper changes that invert the
39
+ engine's dependencies (so the upstream platform can consume this as a published
40
+ library) are tracked separately and are out of scope here. Bug fixes,
41
+ documentation, examples, and build/CI improvements are all welcome.
42
+
43
+ ## Reporting issues
44
+
45
+ Please include the command you ran, the full output, your `rustc --version`, and
46
+ your OS. For enforcement bugs (masking/row-filter/DP), a minimal reproduction
47
+ that constructs the engine in memory (as the examples do) is ideal.