vectra-client 0.3.0 → 0.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15a003ec47ff2de6ec1977426169ffe1739f5fc9ba07cfcd717ca9cb88fd398f
4
- data.tar.gz: ed77f5c22fd580990ee4beaa1840175329c3feda9dd9b6087ad6ff93fec9743a
3
+ metadata.gz: 2d3586fe349f6746ba939c2596bf5b1110551a8e7ed16a8dc6581eaa2f91af81
4
+ data.tar.gz: 11d141983fba57e97fc0d96792f75e8e2e50eac453671ddb25ce8456002acac2
5
5
  SHA512:
6
- metadata.gz: aa3f0556520ceb6677816ffa26ec4beac0fa85f660bdebf28578f47b834c43b87ab5208057ca81b96a9e52a9dd3e645e1c406ceab254a2ade5c716fdcb7a497d
7
- data.tar.gz: 55c2e660ba45abc710cd6d9bc978df5d6c5f23e1e9c058359e719d4d2d43e523af30207fa2ad5b049eb87b698c52c5adf59fe37c4619224986a3c0295d8a408f
6
+ metadata.gz: 6396f52e61633d9b2eed5502edbc80f8c001d85aea638afad4ff5c377e7d141ca80dd6198ace23808324411355924b2e653aa661e157fa4ae33c0b905bf31e4d
7
+ data.tar.gz: 1581ca62c63111caaf6fc26ced7503a101ceb30c8a0531b3fa454a0ac10376446f5a358dfbb29f045de9ba799114803af02b6a021828debc8df14cab129a5147
data/CHANGELOG.md CHANGED
@@ -7,7 +7,73 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [0.3.0] - 2025-01-08
10
+ ### Added
11
+
12
+ - **Proactive Rate Limiting** (`Vectra::RateLimiter`)
13
+ - Token bucket algorithm for smooth rate limiting
14
+ - Burst support for handling traffic spikes
15
+ - Per-provider rate limiter registry
16
+ - `RateLimitedClient` wrapper for automatic throttling
17
+ - Prevents API rate limit errors before they occur
18
+
19
+ - **Structured JSON Logging** (`Vectra::JsonLogger`)
20
+ - Machine-readable JSON log format
21
+ - Automatic operation logging via instrumentation
22
+ - Custom metadata support
23
+ - Integration with standard Ruby Logger via `JsonFormatter`
24
+ - Log levels: debug, info, warn, error, fatal
25
+
26
+ - **Health Check Functionality** (`Vectra::HealthCheck`)
27
+ - Built-in `client.health_check` method
28
+ - Connectivity and latency testing
29
+ - Optional index statistics inclusion
30
+ - Pool health checking for pgvector
31
+ - `AggregateHealthCheck` for multi-provider setups
32
+ - JSON-serializable results
33
+
34
+ - **Error Tracking Integrations**
35
+ - Sentry adapter with breadcrumbs, context, and fingerprinting
36
+ - Honeybadger adapter with severity tags and configurable notifications
37
+ - Automatic error context and grouping
38
+
39
+ - **Circuit Breaker Pattern** (`Vectra::CircuitBreaker`)
40
+ - Three-state circuit (closed, open, half-open)
41
+ - Automatic failover with fallback support
42
+ - Per-provider circuit registry
43
+ - Thread-safe implementation
44
+ - Configurable failure/success thresholds
45
+
46
+ - **Credential Rotation** (`Vectra::CredentialRotator`)
47
+ - Zero-downtime API key rotation
48
+ - Pre-rotation validation
49
+ - Rollback support
50
+ - Multi-provider rotation manager
51
+ - Per-provider rotation tracking
52
+
53
+ - **Audit Logging** (`Vectra::AuditLog`)
54
+ - Structured audit events for compliance
55
+ - Access, authentication, authorization logging
56
+ - Configuration change tracking
57
+ - Credential rotation audit trail
58
+ - Automatic API key sanitization
59
+ - Global audit logging support
60
+
61
+ ## [v0.3.2](https://github.com/stokry/vectra/tree/v0.3.2) (2026-01-08)
62
+
63
+ [Full Changelog](https://github.com/stokry/vectra/compare/v0.3.1...v0.3.2)
64
+
65
+ ### Fixed
66
+
67
+ - Audit log keyword parameter ordering and optional fields now align with linting and usage expectations.
68
+ - Credential rotation utilities use symbol procs and string interpolation while keeping the existing `switch_to_secondary` API.
69
+
70
+ ## [v0.3.1](https://github.com/stokry/vectra/tree/v0.3.1) (2026-01-08)
71
+
72
+ [Full Changelog](https://github.com/stokry/vectra/compare/v0.3.0...v0.3.1)
73
+
74
+ ## [v0.3.0](https://github.com/stokry/vectra/tree/v0.3.0) (2026-01-08)
75
+
76
+ [Full Changelog](https://github.com/stokry/vectra/compare/v0.2.2...v0.3.0)
11
77
 
12
78
  ### Added
13
79
 
@@ -52,7 +118,13 @@ New configuration options:
52
118
 
53
119
  - Added `concurrent-ruby ~> 1.2` for thread-safe operations
54
120
 
55
- ## [0.2.1] - 2025-01-08
121
+ ## [v0.2.2](https://github.com/stokry/vectra/tree/v0.2.2) (2026-01-08)
122
+
123
+ [Full Changelog](https://github.com/stokry/vectra/compare/v0.2.1...v0.2.2)
124
+
125
+ ## [v0.2.1](https://github.com/stokry/vectra/tree/v0.2.1) (2026-01-08)
126
+
127
+ [Full Changelog](https://github.com/stokry/vectra/compare/v0.2.0...v0.2.1)
56
128
 
57
129
  ### Added
58
130
 
@@ -77,9 +149,11 @@ New configuration options:
77
149
  - ✅ Pinecone - Fully implemented
78
150
  - ✅ pgvector (PostgreSQL) - Fully implemented
79
151
  - ✅ Qdrant - Fully implemented
80
- - 🚧 Weaviate - Stub implementation (planned for v0.3.0)
152
+ - 🚧 Weaviate - Stub implementation (planned for v0.4.0)
153
+
154
+ ## [v0.2.0](https://github.com/stokry/vectra/tree/v0.2.0) (2026-01-08)
81
155
 
82
- ## [0.2.0] - 2025-01-08
156
+ [Full Changelog](https://github.com/stokry/vectra/compare/v0.1.3...v0.2.0)
83
157
 
84
158
  ### Added
85
159
 
@@ -102,7 +176,13 @@ New configuration options:
102
176
  - Added IMPLEMENTATION_GUIDE.md for developers implementing new features
103
177
  - Added NEW_FEATURES_v0.2.0.md with migration guide
104
178
 
105
- ## [0.1.1] - 2025-01-07
179
+ ## [v0.1.3](https://github.com/stokry/vectra/tree/v0.1.3) (2026-01-07)
180
+
181
+ [Full Changelog](https://github.com/stokry/vectra/compare/v0.1.1...v0.1.3)
182
+
183
+ ## [v0.1.1](https://github.com/stokry/vectra/tree/v0.1.1) (2026-01-07)
184
+
185
+ [Full Changelog](https://github.com/stokry/vectra/compare/0ab2ea7b42d7fbf0b540b24889cc2b24254fef2e...v0.1.1)
106
186
 
107
187
  ### Added
108
188
 
@@ -121,37 +201,6 @@ New configuration options:
121
201
  - Updated gemspec description to include pgvector
122
202
  - Added `pg` gem as development dependency
123
203
 
124
- ## [0.1.0] - 2024-XX-XX
125
-
126
- ### Added
127
-
128
- - Initial release
129
- - Pinecone provider with full support for:
130
- - Vector upsert, query, fetch, update, delete operations
131
- - Index management (list, describe, create, delete)
132
- - Namespace support
133
- - Metadata filtering
134
- - Configuration system with global and per-client options
135
- - Automatic retry logic with exponential backoff
136
- - Comprehensive error handling with specific error classes:
137
- - `AuthenticationError` - API key issues
138
- - `RateLimitError` - Rate limiting with retry-after
139
- - `NotFoundError` - Resource not found
140
- - `ValidationError` - Invalid request parameters
141
- - `ServerError` - Server-side errors
142
- - `ConnectionError` - Network issues
143
- - `TimeoutError` - Request timeouts
144
- - `Vector` class for vector representation with:
145
- - Cosine similarity calculation
146
- - Euclidean distance calculation
147
- - Metadata support
148
- - `QueryResult` class with Enumerable support:
149
- - Score filtering
150
- - Easy iteration
151
- - Result statistics
152
- - Full RSpec test suite
153
- - YARD documentation
154
-
155
204
  ## Planned
156
205
 
157
206
  ### [0.4.0]
@@ -164,4 +213,4 @@ New configuration options:
164
213
 
165
214
  - Background job integration (Sidekiq, GoodJob)
166
215
  - Production-ready with full documentation
167
- - Performance monitoring dashboard
216
+ - Performance monitoring dashboard
data/SECURITY.md CHANGED
@@ -46,30 +46,100 @@ We will:
46
46
 
47
47
  ### API Key Management
48
48
 
49
+ **CRITICAL: Always use environment variables or secure vaults for API keys.**
50
+
49
51
  - **Never commit API keys** to version control
50
- - Store API keys in environment variables or secure vaults
52
+ - Store API keys in environment variables or secure vaults (AWS Secrets Manager, HashiCorp Vault, etc.)
51
53
  - Use different API keys for development, staging, and production
52
- - Rotate API keys regularly
54
+ - Rotate API keys regularly (every 90 days recommended)
53
55
  - Limit API key permissions to minimum required access
56
+ - Monitor API key usage for anomalies
54
57
 
55
58
  ```ruby
56
59
  # ✅ Good - Use environment variables
57
60
  Vectra.configure do |config|
58
- config.api_key = ENV['PINECONE_API_KEY']
61
+ config.provider = :pinecone
62
+ config.api_key = ENV['PINECONE_API_KEY'] # Set in environment
63
+ config.environment = ENV['PINECONE_ENVIRONMENT'] || 'us-east-1'
64
+ end
65
+
66
+ # ✅ Good - Use Rails credentials (encrypted)
67
+ Vectra.configure do |config|
68
+ config.api_key = Rails.application.credentials.dig(:pinecone, :api_key)
69
+ end
70
+
71
+ # ✅ Good - Use AWS Secrets Manager
72
+ require 'aws-sdk-secretsmanager'
73
+ secrets = Aws::SecretsManager::Client.new
74
+ secret = JSON.parse(secrets.get_secret_value(secret_id: 'vectra/pinecone').secret_string)
75
+
76
+ Vectra.configure do |config|
77
+ config.api_key = secret['api_key']
59
78
  end
60
79
 
61
80
  # ❌ Bad - Hardcoded API key
62
81
  Vectra.configure do |config|
63
- config.api_key = "pk-123456789" # Never do this!
82
+ config.api_key = "pk-123456789" # NEVER DO THIS!
64
83
  end
84
+
85
+ # ❌ Bad - API key in config file
86
+ # config/vectra.yml
87
+ # api_key: "pk-123456789" # This will be committed to git!
88
+ ```
89
+
90
+ ### Credential Rotation
91
+
92
+ Use built-in credential rotation helpers for zero-downtime key rotation:
93
+
94
+ ```ruby
95
+ require 'vectra/credential_rotation'
96
+
97
+ # Setup rotation
98
+ rotator = Vectra::CredentialRotator.new(
99
+ primary_key: ENV['PINECONE_API_KEY'],
100
+ secondary_key: ENV['PINECONE_API_KEY_NEW'],
101
+ provider: :pinecone
102
+ )
103
+
104
+ # Test new key before switching
105
+ if rotator.test_secondary
106
+ rotator.switch_to_secondary
107
+ puts "Rotation complete!"
108
+ else
109
+ puts "New key validation failed - keeping primary"
110
+ end
111
+
112
+ # Rollback if needed
113
+ rotator.rollback
65
114
  ```
66
115
 
116
+ **Rotation Best Practices:**
117
+
118
+ 1. **Test new credentials** before switching
119
+ 2. **Monitor for errors** after rotation
120
+ 3. **Keep old key active** for 24-48 hours after rotation
121
+ 4. **Rotate during low-traffic periods** when possible
122
+ 5. **Use gradual migration** for high-traffic systems
123
+
67
124
  ### Network Security
68
125
 
69
126
  - Always use HTTPS for API connections (enforced by default)
70
127
  - Verify SSL certificates (enabled by default)
71
128
  - Use VPN or private networks when possible
72
129
  - Monitor API usage for unusual patterns
130
+ - **mTLS Support**: For providers that support mutual TLS, configure client certificates
131
+
132
+ ```ruby
133
+ # mTLS configuration (provider-specific)
134
+ # Note: mTLS support depends on provider capabilities
135
+ # For pgvector, use SSL connection parameters:
136
+ Vectra.configure do |config|
137
+ config.provider = :pgvector
138
+ config.host = "postgresql://user:pass@host/db?sslmode=verify-full&sslcert=/path/to/client.crt&sslkey=/path/to/client.key"
139
+ end
140
+
141
+ # For cloud providers, check provider documentation for mTLS setup
142
+ ```
73
143
 
74
144
  ### Data Security
75
145
 
@@ -137,6 +207,7 @@ end
137
207
  - Monitor for authentication failures
138
208
  - Track unusual query patterns
139
209
  - Set up alerts for rate limit violations
210
+ - **Enable audit logging** for compliance requirements
140
211
 
141
212
  ```ruby
142
213
  # ❌ Bad - Logs API key
@@ -144,8 +215,67 @@ logger.info("Using API key: #{config.api_key}")
144
215
 
145
216
  # ✅ Good - Logs without sensitive data
146
217
  logger.info("Initializing Vectra client for #{config.provider}")
218
+
219
+ # ✅ Good - Use audit logging for security events
220
+ require 'vectra/audit_log'
221
+
222
+ audit = Vectra::AuditLog.new(output: "log/audit.json.log")
223
+
224
+ # Log access events
225
+ audit.log_access(
226
+ user_id: current_user.id,
227
+ operation: "query",
228
+ index: "sensitive-data",
229
+ result_count: 10
230
+ )
231
+
232
+ # Log authentication events
233
+ audit.log_authentication(
234
+ user_id: user.id,
235
+ success: true,
236
+ provider: "pinecone"
237
+ )
238
+
239
+ # Log credential rotations
240
+ audit.log_credential_rotation(
241
+ provider: "pinecone",
242
+ success: true,
243
+ rotated_by: admin_user.id
244
+ )
245
+ ```
246
+
247
+ ### Audit Logging
248
+
249
+ For compliance and security auditing:
250
+
251
+ ```ruby
252
+ # Setup global audit logging
253
+ Vectra::AuditLogging.setup!(
254
+ output: "log/audit.json.log",
255
+ app: "my-service",
256
+ env: Rails.env
257
+ )
258
+
259
+ # Automatic audit logging for operations
260
+ Vectra::Instrumentation.on_operation do |event|
261
+ Vectra::AuditLogging.log(:access,
262
+ user_id: current_user&.id,
263
+ operation: event.operation,
264
+ index: event.index,
265
+ success: event.success?
266
+ )
267
+ end
147
268
  ```
148
269
 
270
+ **Audit Log Events:**
271
+ - `access` - Data access operations
272
+ - `authentication` - Auth success/failure
273
+ - `authorization` - Permission checks
274
+ - `configuration_change` - Config modifications
275
+ - `credential_rotation` - Key rotations
276
+ - `data_modification` - Upsert/delete/update
277
+ - `error` - Security-relevant errors
278
+
149
279
  ## Known Security Considerations
150
280
 
151
281
  ### API Key Exposure
@@ -35,6 +35,8 @@
35
35
  <li><a href="{{ site.baseurl }}/guides/installation" class="tma-sidebar__link {% if page.url == '/guides/installation/' %}tma-sidebar__link--active{% endif %}">Installation</a></li>
36
36
  <li><a href="{{ site.baseurl }}/guides/getting-started" class="tma-sidebar__link {% if page.url == '/guides/getting-started/' %}tma-sidebar__link--active{% endif %}">Quick Start</a></li>
37
37
  <li><a href="{{ site.baseurl }}/guides/performance" class="tma-sidebar__link {% if page.url == '/guides/performance/' %}tma-sidebar__link--active{% endif %}">Performance</a></li>
38
+ <li><a href="{{ site.baseurl }}/guides/monitoring" class="tma-sidebar__link {% if page.url == '/guides/monitoring/' %}tma-sidebar__link--active{% endif %}">Monitoring</a></li>
39
+ <li><a href="{{ site.baseurl }}/guides/security" class="tma-sidebar__link {% if page.url == '/guides/security/' %}tma-sidebar__link--active{% endif %}">Security</a></li>
38
40
  </ul>
39
41
  </div>
40
42