prismlib-plus 0.7.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 (80) hide show
  1. prismlib_plus-0.7.0/BENCHMARK_RESULTS.md +119 -0
  2. prismlib_plus-0.7.0/CHANGELOG.md +70 -0
  3. prismlib_plus-0.7.0/ENTERPRISE.md +126 -0
  4. prismlib_plus-0.7.0/MANIFEST.in +9 -0
  5. prismlib_plus-0.7.0/PKG-INFO +748 -0
  6. prismlib_plus-0.7.0/README.md +659 -0
  7. prismlib_plus-0.7.0/RELEASE_NOTES.md +159 -0
  8. prismlib_plus-0.7.0/RESULTS_AND_IMPROVEMENTS.md +119 -0
  9. prismlib_plus-0.7.0/SECURITY.md +61 -0
  10. prismlib_plus-0.7.0/prism/__init__.py +9 -0
  11. prismlib_plus-0.7.0/prism/api/__init__.py +83 -0
  12. prismlib_plus-0.7.0/prism/api/auth.py +127 -0
  13. prismlib_plus-0.7.0/prism/api/consumer.py +573 -0
  14. prismlib_plus-0.7.0/prism/api/integrations/__init__.py +30 -0
  15. prismlib_plus-0.7.0/prism/api/integrations/langgraph.py +382 -0
  16. prismlib_plus-0.7.0/prism/api/mcp.py +341 -0
  17. prismlib_plus-0.7.0/prism/api/multi_provider.py +315 -0
  18. prismlib_plus-0.7.0/prism/api/provider.py +496 -0
  19. prismlib_plus-0.7.0/prism/api/schema.py +296 -0
  20. prismlib_plus-0.7.0/prism/bridge/__init__.py +32 -0
  21. prismlib_plus-0.7.0/prism/bridge/vector.py +704 -0
  22. prismlib_plus-0.7.0/prism/cache/__init__.py +54 -0
  23. prismlib_plus-0.7.0/prism/cache/cache.py +637 -0
  24. prismlib_plus-0.7.0/prism/cache/embedder.py +438 -0
  25. prismlib_plus-0.7.0/prism/cache/metrics.py +273 -0
  26. prismlib_plus-0.7.0/prism/cache/store.py +370 -0
  27. prismlib_plus-0.7.0/prism/cluster/__init__.py +20 -0
  28. prismlib_plus-0.7.0/prism/cluster/alerts.py +550 -0
  29. prismlib_plus-0.7.0/prism/cluster/cache.py +480 -0
  30. prismlib_plus-0.7.0/prism/cluster/health.py +87 -0
  31. prismlib_plus-0.7.0/prism/cluster/node.py +288 -0
  32. prismlib_plus-0.7.0/prism/cluster/transport.py +81 -0
  33. prismlib_plus-0.7.0/prism/enterprise/__init__.py +5 -0
  34. prismlib_plus-0.7.0/prism/enterprise/app.py +70 -0
  35. prismlib_plus-0.7.0/prism/ffi/__init__.py +34 -0
  36. prismlib_plus-0.7.0/prism/ffi/bindings.py +1055 -0
  37. prismlib_plus-0.7.0/prism/ffi/grpc_client.py +121 -0
  38. prismlib_plus-0.7.0/prism/lib/__init__.py +17 -0
  39. prismlib_plus-0.7.0/prism/lib/fabric.py +1141 -0
  40. prismlib_plus-0.7.0/prism/lib/lang.py +531 -0
  41. prismlib_plus-0.7.0/prism/lib/resonance.py +691 -0
  42. prismlib_plus-0.7.0/prism/observability/__init__.py +110 -0
  43. prismlib_plus-0.7.0/prism/observability/otel.py +85 -0
  44. prismlib_plus-0.7.0/prism/observability/prometheus.py +11 -0
  45. prismlib_plus-0.7.0/prism/security/__init__.py +17 -0
  46. prismlib_plus-0.7.0/prism/security/audit.py +80 -0
  47. prismlib_plus-0.7.0/prism/security/rate_limit.py +74 -0
  48. prismlib_plus-0.7.0/prism/security/tls.py +48 -0
  49. prismlib_plus-0.7.0/prism/wrapper/__init__.py +49 -0
  50. prismlib_plus-0.7.0/prism/wrapper/config.py +132 -0
  51. prismlib_plus-0.7.0/prism/wrapper/daemon.py +261 -0
  52. prismlib_plus-0.7.0/prism/wrapper/grpc_server.py +248 -0
  53. prismlib_plus-0.7.0/prism/wrapper/interceptor.py +543 -0
  54. prismlib_plus-0.7.0/prism/wrapper/main.py +5 -0
  55. prismlib_plus-0.7.0/prism/wrapper/proto/__init__.py +0 -0
  56. prismlib_plus-0.7.0/prism/wrapper/proto/chorus_pb2.py +71 -0
  57. prismlib_plus-0.7.0/prism/wrapper/proto/chorus_pb2_grpc.py +454 -0
  58. prismlib_plus-0.7.0/prism/wrapper/publisher.py +255 -0
  59. prismlib_plus-0.7.0/prism/wrapper/row_events.py +129 -0
  60. prismlib_plus-0.7.0/prism/wrapper/subscribe_server.py +78 -0
  61. prismlib_plus-0.7.0/prismlib_plus.egg-info/PKG-INFO +748 -0
  62. prismlib_plus-0.7.0/prismlib_plus.egg-info/SOURCES.txt +78 -0
  63. prismlib_plus-0.7.0/prismlib_plus.egg-info/dependency_links.txt +1 -0
  64. prismlib_plus-0.7.0/prismlib_plus.egg-info/entry_points.txt +2 -0
  65. prismlib_plus-0.7.0/prismlib_plus.egg-info/requires.txt +85 -0
  66. prismlib_plus-0.7.0/prismlib_plus.egg-info/top_level.txt +1 -0
  67. prismlib_plus-0.7.0/proto/chorus.proto +184 -0
  68. prismlib_plus-0.7.0/pyproject.toml +155 -0
  69. prismlib_plus-0.7.0/setup.cfg +4 -0
  70. prismlib_plus-0.7.0/tests/test_bridge_vector.py +245 -0
  71. prismlib_plus-0.7.0/tests/test_cache.py +450 -0
  72. prismlib_plus-0.7.0/tests/test_cluster.py +52 -0
  73. prismlib_plus-0.7.0/tests/test_enterprise.py +135 -0
  74. prismlib_plus-0.7.0/tests/test_fabric.py +142 -0
  75. prismlib_plus-0.7.0/tests/test_ffi.py +148 -0
  76. prismlib_plus-0.7.0/tests/test_grpc_client.py +79 -0
  77. prismlib_plus-0.7.0/tests/test_lang.py +175 -0
  78. prismlib_plus-0.7.0/tests/test_resonance.py +194 -0
  79. prismlib_plus-0.7.0/tests/test_security.py +102 -0
  80. prismlib_plus-0.7.0/tests/test_wrapper.py +331 -0
@@ -0,0 +1,119 @@
1
+ # PrismLib — Benchmark Results (single source of truth)
2
+
3
+ All numbers below are from **real runs**. Two environments:
4
+
5
+ - **Cache & Driver layers** — Azure Container Apps (westus2), concurrent load test
6
+ - **Cluster mesh** — Azure Container Apps (westus2), 3 nodes across 2 VNets
7
+
8
+ Raw data:
9
+ - `benchmark/results/prism_mixed_*_report.json`, `prism_light_*_report.json` (cache)
10
+ - `benchmark/results/driver_benchmark_azure.json` (driver e2e, latest)
11
+ - `benchmark/results/driver_benchmark_*.json` (driver history)
12
+ - `benchmark/cluster/cluster_benchmark_results_azure.json` (cluster mesh)
13
+ - `benchmark/cluster/cluster_benchmark_results_loopback.json` (earlier loopback run, for reference)
14
+
15
+ ---
16
+
17
+ ## 1. PrismCache — semantic LLM cache (Azure, concurrent load)
18
+
19
+ | Scenario | Users | Duration | Queries | Hit rate | Tokens saved | Monthly est. saved |
20
+ |----------|-------|----------|---------|----------|--------------|--------------------|
21
+ | Light | 20 | 60 s | 4,050 | 91.0–92.0% | 953,344 | ~$412 |
22
+ | Mixed | 50 | 300 s | 6,973 | **95.9%** | 1,673,216 | ~$723 |
23
+
24
+ Avg hit latency ~291 ms, avg miss latency ~415 ms (mixed scenario).
25
+
26
+ ## 2. PrismDriver — WAL-streamed DB driver (Azure, 2-container e2e)
27
+
28
+ **Deploy:** `deploy/azure_driver_run.ps1` (or `.sh`)
29
+ **Topology:** `prism-wrapper-sim` (DB node) + `prism-benchmark` (app node with Python PrismDriver)
30
+ **Latest run:** 2026-06-29 — `benchmark/results/driver_benchmark_azure.json`
31
+ **Logs:** `benchmark/results/azure_e2e_logs/`
32
+
33
+ | Path | Avg read latency | Result |
34
+ |------|------------------|--------|
35
+ | Baseline (network to DB) | 118.5 ms | — |
36
+ | PrismDriver (local index, Python mode) | **0.27 ms** | **439× faster · 99.8% latency reduction** |
37
+
38
+ 20 concurrent users × 45 s/phase, 1,000-row catalog, WAL subscribe warmup ~51k rows/s ingest.
39
+ Driver mode: `python` (C++ DLL not built in OSS repo).
40
+
41
+ **Container URLs (rg-prism-driver-e2e, westus2):**
42
+ - App: `https://prism-benchmark.gentlesmoke-8bb70e10.westus2.azurecontainerapps.io`
43
+ - DB: `https://prism-wrapper-sim.gentlesmoke-8bb70e10.westus2.azurecontainerapps.io`
44
+
45
+ Previous run (2026-06-24): 70.7× / 2.02 ms driver / 142.8 ms baseline — `driver_benchmark_20260624_135338.json`.
46
+
47
+ ---
48
+
49
+ ## 3. Cluster mesh — 3 nodes, Azure Container Apps, 2 VNets (westus2)
50
+
51
+ Topology: GREEN + BLUE in Environment A (one VNet), ORANGE in Environment B
52
+ (separate VNet), benchmark runner external/cross-network.
53
+ Deploy: `deploy/azure_cluster_run.sh`.
54
+
55
+ ### 3.1 Token savings
56
+
57
+ | Node | Role | Network | Tokens billed | Tokens saved | Mechanism | Per-node savings |
58
+ |------|------|---------|---------------|--------------|-----------|------------------|
59
+ | node-green | active | same VNet | 328 | 130 | context compression | 28.4% |
60
+ | node-blue | warm standby | same VNet | 0 | 61 | cluster cache | 100% |
61
+ | node-orange | reserve | cross-VNet | 0 | 75 | cluster cache | 100% |
62
+ | **Cluster avg** | | | | | | **76.1%** |
63
+
64
+ > Note: 76.1% is the arithmetic mean of per-node savings under a workload where
65
+ > warm nodes receive already-answered queries. Conservative reading: savings on
66
+ > a node = (fraction of its queries already answered elsewhere) + 28–64%
67
+ > compression on the rest. High-repeat workloads trend toward the cache figure;
68
+ > low-repeat toward the compression-only figure.
69
+
70
+ ### 3.2 CHORUS frame latency (cross-VNet, same region)
71
+
72
+ | Node | Network | Avg | Min | Max |
73
+ |------|---------|-----|-----|-----|
74
+ | node-green | same VNet | 19.4 ms | 15.0 ms | 29.0 ms |
75
+ | node-blue | same VNet | 19.9 ms | 15.2 ms | 22.6 ms |
76
+ | node-orange | cross-VNet | 21.6 ms | 16.0 ms | 26.3 ms |
77
+
78
+ ### 3.3 Health-alert propagation
79
+
80
+ | Event | Source → Dest | Network | Propagation |
81
+ |-------|---------------|---------|-------------|
82
+ | cpu_high (92%) | GREEN → BLUE | same VNet | 633 ms |
83
+ | cpu_high (92%) | GREEN → ORANGE | cross-VNet | 674 ms |
84
+
85
+ ### 3.4 Failover (leaderless)
86
+
87
+ | Metric | Value |
88
+ |--------|-------|
89
+ | GREEN silence threshold | 3,000 ms |
90
+ | Failover detected | 3,960 ms |
91
+ | Promotion to active (once detected) | 97 ms |
92
+ | Human intervention | none |
93
+
94
+ ### 3.5 Context compression
95
+
96
+ | Query | Tokens used | Tokens saved | Compression |
97
+ |-------|-------------|--------------|-------------|
98
+ | What is PrismLib? | 71 | 126 | 64.0% |
99
+ | How does CHORUS Fabric work? | 85 | 118 | 58.1% |
100
+ | Explain context compression. | 75 | 128 | 63.1% |
101
+ | What is Blue/Green/Orange failover? | 84 | 116 | 58.0% |
102
+ | How does token deduplication work? | 81 | 116 | 58.9% |
103
+ | **Average** | | | **60.4%** |
104
+
105
+ ---
106
+
107
+ ## Scope & honesty notes
108
+
109
+ - Driver e2e uses **wrapper-sim** (in-memory catalog), not production Postgres + `prism-wrapper`. Numbers are real for that topology; validate on your DB before SLAs.
110
+ - Driver ran in **Python mode**; C++ DLL sources are not in the OSS repo.
111
+ - The cluster ran across two VNets but **both in westus2** — cross-*region*
112
+ latency and network-partition behavior are untested.
113
+ - Cluster benchmark is a **functional 3-node run** (5 queries), not a sustained
114
+ load test; the cache/driver layers (§1–2) are the load-tested ones.
115
+ - Leaderless promotion trades Raft-style consensus guarantees for simplicity;
116
+ a partition could briefly produce two actives.
117
+ - Loopback-vs-Azure: token savings and compression were identical (logic, not
118
+ network); only latency/alert/failover timings differ, and the Azure numbers
119
+ are the canonical ones above.
@@ -0,0 +1,70 @@
1
+ # Changelog
2
+
3
+ All notable changes to **prismlib-plus** (superset of [prismlib](https://pypi.org/project/prismlib/) on PyPI).
4
+
5
+ Format based on [Keep a Changelog](https://keepachangelog.com/).
6
+
7
+ ---
8
+
9
+ ## [0.7.0] — 2026-06-29
10
+
11
+ ### Azure-validated benchmarks
12
+
13
+ - **PrismDriver 2-container e2e** (westus2): **118.5 ms → 0.27 ms** (439×, 99.8% latency reduction)
14
+ - Deploy: `deploy/azure_driver_run.ps1` / `.sh`
15
+ - Artifacts: `benchmark/results/driver_benchmark_azure.json`, `benchmark/results/azure_e2e_logs/`
16
+ - **PrismCache** (Azure): 91–96% hit rate under concurrent load
17
+ - **Cluster mesh** (Azure, 3 nodes / 2 VNets): 76% token savings, ~20 ms CHORUS latency, ~4 s failover
18
+
19
+ ### Enterprise & security
20
+
21
+ - `PrismAPI` enterprise FastAPI stack: auth, rate limit, audit, `/health`, `/metrics`
22
+ - mTLS on `WrapperGrpcServer` and `PrismDriver` gRPC client
23
+ - `SECURITY.md` threat model; safe alert rules (no `eval`)
24
+ - MCP server API-key gate (`PRISM_MCP_API_KEY`)
25
+ - Helm chart with API-key secrets, TLS/mTLS projected volumes
26
+ - `ENTERPRISE.md`, `examples/enterprise_server.py`, `enterprise_client.py`, Docker/compose
27
+
28
+ ### Correctness & driver
29
+
30
+ - `LocalIndex` WAL upsert/update/delete by `row_id`
31
+ - `RowEventHub`, HTTP subscribe server, gRPC `WrapperService` (Query/Write/Subscribe)
32
+ - `prism.ffi.grpc_client` — remote Query/Write for Python driver
33
+ - `PrismDriver` gRPC subscription + HTTP fallback (`PRISM_WRAPPER_URL`)
34
+ - Fix: `LocalIndex.is_warm` now reflects ingested rows (was stale `_rows`)
35
+ - Benchmark: `/driver/reset-baseline` preserves warm index between phases
36
+
37
+ ### Observability
38
+
39
+ - Prometheus metrics registry; optional OpenTelemetry spans on cache + API client
40
+ - `ClusterTransport`, `HealthMonitor`, cluster cache invalidation hooks
41
+
42
+ ### Tests
43
+
44
+ - 217+ tests: enterprise, security, cluster, gRPC client, MCP auth
45
+
46
+ ---
47
+
48
+ ## [0.6.0] — 2026-06 (internal)
49
+
50
+ - Initial enterprise tier implementation (auth, gRPC wrapper, observability scaffolding)
51
+ - Version bump in repo; not published to PyPI
52
+
53
+ ---
54
+
55
+ ## PyPI lineage
56
+
57
+ | Package | PyPI version | Source |
58
+ |---------|--------------|--------|
59
+ | `prismlib` | **0.4.0** (latest on PyPI) | [PrismLib](https://github.com/insightitsGit/prismlib) — cache, driver, cluster core |
60
+ | `prismlib-plus` | **0.7.0** (this release) | PrismLabPlusAPI — prismlib + PrismAPI + enterprise |
61
+
62
+ Install the superset:
63
+
64
+ ```bash
65
+ pip install "prismlib-plus[enterprise,cache,fabric]"
66
+ ```
67
+
68
+ To publish as an upgrade to the existing package name, see `RELEASE.md` (optional `prismlib` 0.5.0 rename).
69
+
70
+ **User-facing release announcement:** [RELEASE_NOTES.md](RELEASE_NOTES.md)
@@ -0,0 +1,126 @@
1
+ # Enterprise deployment guide
2
+
3
+ PrismLib Plus (`prismlib-plus` 0.7.0) ships an enterprise HTTP API layer (PrismAPI), optional gRPC wrapper, auth, rate limiting, audit logging, Prometheus metrics, and optional OpenTelemetry tracing.
4
+
5
+ ## Quick start (local)
6
+
7
+ ```bash
8
+ pip install -e ".[enterprise,cache,fabric]"
9
+
10
+ # Terminal 1 — API server (prints a dev API key)
11
+ python examples/enterprise_server.py
12
+
13
+ # Terminal 2 — HTTP client
14
+ export PRISM_API_KEY=<key-from-server>
15
+ python examples/enterprise_client.py --query "return policy"
16
+ ```
17
+
18
+ Loopback golden path (no network):
19
+
20
+ ```bash
21
+ python examples/enterprise_golden_path.py
22
+ ```
23
+
24
+ ## Docker
25
+
26
+ ```bash
27
+ export PRISM_API_KEYS="$(python -c 'from prism.api import generate_api_key; print(generate_api_key())')"
28
+ docker compose -f deploy/docker-compose.enterprise.yml up --build
29
+
30
+ PRISM_API_KEY=$PRISM_API_KEYS python examples/enterprise_client.py
31
+ ```
32
+
33
+ Image build only:
34
+
35
+ ```bash
36
+ docker build -f deploy/Dockerfile.enterprise -t prismlib/enterprise:0.6.0 .
37
+ ```
38
+
39
+ ## Production environment variables
40
+
41
+ | Variable | Purpose |
42
+ |----------|---------|
43
+ | `PRISM_API_KEYS` | Comma-separated API keys |
44
+ | `PRISM_API_REQUIRE_AUTH` | `true` / `false` |
45
+ | `PRISM_API_RATE_LIMIT_RPM` | Requests per minute per client |
46
+ | `PRISM_TENANT_ID` | Tenant isolation for projection |
47
+ | `PRISM_WRAPPER_TLS_CERT` | Server TLS certificate path |
48
+ | `PRISM_WRAPPER_TLS_KEY` | Server TLS private key path |
49
+ | `PRISM_WRAPPER_TLS_CA` | CA for mTLS client verification |
50
+ | `PRISM_WRAPPER_REQUIRE_CLIENT_CERT` | Require client certs on gRPC |
51
+ | `PRISM_DRIVER_TLS_CA` | Driver trust anchor |
52
+ | `PRISM_DRIVER_TLS_CLIENT_CERT` | Driver client certificate |
53
+ | `PRISM_DRIVER_TLS_CLIENT_KEY` | Driver client private key |
54
+ | `PRISM_MCP_API_KEY` | MCP tool `api_key` gate |
55
+
56
+ Generate dev mTLS certs (requires OpenSSL on PATH):
57
+
58
+ ```bash
59
+ python scripts/gen_dev_certs.py --out certs/dev
60
+ ```
61
+
62
+ ## Kubernetes (Helm)
63
+
64
+ ```bash
65
+ # Create secrets out-of-band (recommended)
66
+ kubectl create secret generic prism-api-keys \
67
+ --from-literal=PRISM_API_KEYS="$(python -c 'from prism.api import generate_api_key; print(generate_api_key())')"
68
+
69
+ kubectl create secret tls prism-tls --cert=tls.crt --key=tls.key
70
+ kubectl create secret generic prism-mtls-ca --from-file=ca.crt=ca.pem
71
+
72
+ helm upgrade --install prismlib deploy/helm/prismlib \
73
+ --set image.repository=prismlib/enterprise \
74
+ --set image.tag=0.6.0 \
75
+ --set auth.apiKeySecret=prism-api-keys \
76
+ --set tls.certSecret=prism-tls \
77
+ --set tls.caSecret=prism-mtls-ca
78
+ ```
79
+
80
+ Endpoints:
81
+
82
+ - `POST /chorus/search` — CHORUS binary frames (`Content-Type: application/x-chorus-frame`)
83
+ - `GET /health` — liveness
84
+ - `GET /metrics` — Prometheus scrape target
85
+ - `GET /audit/recent` — last 100 security events
86
+
87
+ ## gRPC wrapper (optional sidecar)
88
+
89
+ Run the DB-node wrapper daemon with mTLS:
90
+
91
+ ```bash
92
+ export PRISM_WRAPPER_TLS_CERT=certs/dev/server.crt
93
+ export PRISM_WRAPPER_TLS_KEY=certs/dev/server.key
94
+ export PRISM_WRAPPER_TLS_CA=certs/dev/ca.pem
95
+ prism-wrapper --grpc-port 50051
96
+ ```
97
+
98
+ Python driver remote query uses `WrapperService.Query` when gRPC stubs are installed.
99
+
100
+ ## Observability
101
+
102
+ Prometheus metrics are always available at `/metrics`.
103
+
104
+ OpenTelemetry (optional):
105
+
106
+ ```bash
107
+ pip install "prismlib-plus[otel]"
108
+ ```
109
+
110
+ ```python
111
+ from prism.observability.otel import configure_tracing
112
+ configure_tracing("my-service", otlp_endpoint="http://otel-collector:4317")
113
+ ```
114
+
115
+ Spans are emitted for `PrismCache.get_or_call` and `PrismAPIClient.query`.
116
+
117
+ ## Security
118
+
119
+ See [SECURITY.md](SECURITY.md) for the threat model, TLS defaults, and audit log fields.
120
+
121
+ ## MCP server
122
+
123
+ ```bash
124
+ export PRISM_MCP_API_KEY=your-key
125
+ python -m prism.api.mcp # pass api_key in tool arguments when auth enabled
126
+ ```
@@ -0,0 +1,9 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include RELEASE_NOTES.md
5
+ include SECURITY.md
6
+ include ENTERPRISE.md
7
+ include RESULTS_AND_IMPROVEMENTS.md
8
+ include BENCHMARK_RESULTS.md
9
+ recursive-include proto *.proto